我的Maven项目中有一个依赖库。该库包含JPA2实体。在构建过程中仅生成根项目中实体的模型,而不是来自库中实体的模型。我已经尝试过eclipse链接生成器(CanonicalModelProcessor)和hibernate生成器(JPAMetaModelEntityProcessor)我无法找到任何配置参数,这些参数也包括对元模型生成的项目依赖性。我找不到任何相关的搜索网络。我还尝试通过类标记手动命名persistence.xml中持久性单元中的所有实体(包括库实体)
<class>com.example.project.domain.CustomEntity</class>
并尝试通过
开启自动发现功能<exclude-unlisted-classes>false</exclude-unlisted-classes>
没有任何帮助。为了列出所有细节,我使用的是Netbeans 8.0.2,项目设置为Java 7和J2EE7。贝娄是两个发电机的pom例子。
休眠:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<annotationProcessors>
<annotationProcessor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</annotationProcessor>
</annotationProcessors>
<debug>true</debug>
<optimize>true</optimize>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<AaddGeneratedAnnotation>true</AaddGeneratedAnnotation>
<Adebug>true</Adebug>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
<outputDirectory>${project.build.directory}/generated-sources/meta-model</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.8.Final</version>
<optional>true</optional>
</dependency>
</dependencies>
</plugin>
的EclipseLink:
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>eclipselink-jpa-metamodel</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
</processors>
<outputDirectory>${project.build.directory}/generated-sources/meta-model</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</plugin>
答案 0 :(得分:1)
看起来Neil Stockton是对的。我找到了两个可能解决这个问题的方法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/persistence.xml</exclude>
</excludes>
</configuration>
</plugin>