14
我遵循JPA modelgen guide,我能够生成我需要的规范元模型。有了这个POM设置:JPA Hibernate通过maven生成元模型
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.6-redhat</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>target/metamodel</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/metamodel</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
生成的源在指定目录中正确地创建和我必须手动将它指定Eclipse项目类路径中的源来使用它。当我触发一个maven日志显示cannot find symbol
或duplicate class
,我仍然获得成功构建。所以我的问题是,创建元模型的这种预期/正确的行为?还是我错过了cofig的东西?由于
FIY,看看[jpa-metamodel-with-maven](https://jinahya.wordpress.com/2014/03/29/jpa-metamodel-with-maven/) –