如何配置JPAMetaModelEntityProcessor以不获取"重复类"错误?

Sle*_*led 3 java jpa maven

我试图使用hibernate-jpamodelgen与maven-processor-plugin一起使用此答案的配置生成我的JPA元模型作为我的Maven构建的一部分.

但是,当我进行构建时,当我尝试执行以下操作时出现以下错误mvn clean install:

[ERROR] C:\Users\ArtB\Documents\code\xxx\target\classes\me\Page_.java:[11,16] error: duplicate class: me.Page_  
Run Code Online (Sandbox Code Playgroud)

从一些调查来看,问题是生成的元模型似乎发生了两次或者其他什么.

如果我运行clear; mvn clean generate-sources; ls -l target\generated-sources\apt\me我只有文件_Page.java,没有其他文件.

compile阶段之后target\classes\文件夹只包含\me\_Page.java...这看起来很奇怪,因为我认为.class文件应该出现在"\ target\classes"文件夹中.

我使用debug(即-X)运行构建,并没有看到任何可疑的东西.


我怀疑这很重要,但这是我的模特.

package me;

@Entity
@Table(name="Pages")
public class Page {

    @Id @GeneratedValue
    private long id;

    private String title;
    private Instant lastRetrieved;
    private PageCategory category;
    private URL source;

    @Lob
    private String contents;

    //hashcode, equals, getters & setters omitted
}
Run Code Online (Sandbox Code Playgroud)

package me;

public enum PageCategory {
    PRODUCT,
    INFO
    ;
}
Run Code Online (Sandbox Code Playgroud)

Sle*_*led 8

显然,您不需要处理器插件.只是常规编译器工作.我评论了整个

<!--
<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>             
    <version>2.2.4</version>
    <executions>
        <execution>
            <id>process</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <processors>
                    <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                </processors>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>4.3.6.Final</version>
        </dependency>
    </dependencies>
</plugin>
-->
Run Code Online (Sandbox Code Playgroud)

部分,它工作正常...去图.我的编译器配置是:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)