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/) –