Why doesn't NetBeans IDE see the generated sources?

后端 未结 6 2184
离开以前
离开以前 2021-02-07 02:55

I have a Maven-built web-app that uses JPA 2.0 at the back end. The JPA provider is EclipseLink 2.3.2.

When I build the project (and it deploys runs successfully) it bu

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 03:06

    After reading @jeqo answer, I tested if, by manually renaming:

     "${project.build.directory}/generated-sources/annotations" to ".../generated-sources/hibernate-jpamodelgen" 
    

    would make a difference to Nebeans (I'm using v8.2 on ubuntu 16.04).

    Everything worked like a charm.

    I then modified the pom file as follows:

    1) removed the "org.hibernate: hibernate.jpamodelgen" dependency.

    2) configured the maven-compiler-plugin as follows:

       
        >org.apache.maven.plugins
        maven-compiler-plugin
        3.6.1
        
          -proc:none        
        
      
    
    • These two steps is to make sure that the hibernate-jpamodelgen does not run on auto-pilot just by adding it in the project dependency list. Please refer to JPA Static MetaModel Generator doc.

    3) added the following plugin with configuration

      
        org.bsc.maven
        maven-processor-plugin
        3.2.0
        
          
            process
            
              process
            
            generate-sources
            
              
                org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
              
              ${project.build.directory}/generated-sources/hibernate-jpamodelgen/
            
          
        
        
          
            org.hibernate
            hibernate-jpamodelgen
            5.2.9.Final
          
        
      
    

    This config is directly from the Hibernate JPA Static Metamodel Generator documentation page except for the following line:

    ${project.build.directory}/generated-sources/hibernate-jpamodelgen/
    

    This line simply generates the metamodel in the directory named after the maven plugin name. From this point, I got all Netbeans references working at design time as if the generated classes were in the src directory subtree.

    Hope this helps,

    J

提交回复
热议问题