我的 Maven 项目已经成长,所以我决定尝试制作一个 Maven 多模块项目。
我认为它似乎工作正常,除了 Eclipselink 元模型类生成。
这是运行时mvn clean generate-sources
不期望的输出:
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=/home/glassfish/git/vehiclecms/vehiclecms-parent/vehiclecms-backend/src/main/resources/META-INF/persistence.xml
-Aeclipselink.persistenceunits=carcmsPU
-Aeclipselink.canonicalmodel.subpackage=metamodel
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: /home/glassfish/git/vehiclecms/vehiclecms-parent/vehiclecms-backend/target/classes
[INFO] javac option: -s
[INFO] javac option: /home/glassfish/git/vehiclecms/vehiclecms-parent/vehiclecms-backend/target/generated-sources
[INFO] diagnostic warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.7'
[INFO] diagnostic Note: Creating static metadata factory ...
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: /home/glassfish/git/vehiclecms/vehiclecms-parent/vehiclecms-backend/src/main/resources/META-INF/persistence.xml
-Aeclipselink.persistenceunits=carcmsPU
-Aeclipselink.canonicalmodel.subpackage=metamodel
[INFO] diagnostic Note: The persistence xml file [/home/glassfish/git/vehiclecms/vehiclecms-parent/vehiclecms-backend/src/main/resources/META-INF/persistence.xml
-Aeclipselink.persistenceunits=carcmsPU
-Aeclipselink.canonicalmodel.subpackage=metamodel] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml] or using the eclipselink.persistencexml property to specify its location.
这部分的 pom.xml 是:
<!-- Generate JPA Criteria Meta Model classes -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.6</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>${basedir}/target/generated-sources</outputDirectory>
<compilerArguments>-Aeclipselink.persistencexml=${basedir}/src/main/resources/META-INF/persistence.xml
-Aeclipselink.persistenceunits=carcmsPU
-Aeclipselink.canonicalmodel.subpackage=metamodel</compilerArguments>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
我不明白为什么这不起作用,这与我在单模块项目中的情况相同。Maven 或 Eclipselink 似乎在多模块项目中不起作用,或者我在这里遗漏了一些东西?