2014-12-09 162 views
1

我有一个GitHub repository,我主持一些Hibernate示例并生成JPA MetaModel类我一直使用下面的Maven插件:org.bsc.maven.maven-processor-plugin不适用于java 1.7及以上版本

<plugin> 
    <groupId>org.bsc.maven</groupId> 
    <artifactId>maven-processor-plugin</artifactId> 
    <version>2.0.5</version> 
    <executions> 
     <execution> 
      <id>process</id> 
      <goals> 
       <goal>process</goal> 
      </goals> 
      <phase>generate-sources</phase> 
      <configuration> 
       <outputDirectory>target/generated-sources/java/</outputDirectory> 
       <processors> 
        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor 
        </processor> 
       </processors> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

在Java 1.6一切运行得很好,但是当我切换到Java 1.7,我得到以下错误:

[INFO] javac option: D:\wrk\vladmihalcea\vladmihalcea.wordpress.com\hibernate-facts\target\generated-sources\java 
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.0.0.Final 
[INFO] diagnostic warning: Supported source version 'RELEASE_6' from annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' less than -source '1.7' 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.Version_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.baglist.BagTree_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.Product_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.Importer_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.linkedset.LinkedParent_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.fetch.FetchChild_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.Company_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.SubVersion_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.baglist.BagLeaf_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.indexlist.Branch_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.linkedset.LinkedChild_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.indexlist.Tree_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.bag.Child_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.baglist.BagForest_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.indexlist.Leaf_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.bag.Parent_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.eagerset.SetParent_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.WarehouseProductInfo_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.eagerset.SetChild_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.fetch.FetchParent_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.store.Image_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.baglist.BagBranch_' created in the last round will not be subject to annotation processing. 
[INFO] diagnostic warning: File for type 'com.vladmihalcea.hibernate.model.indexlist.Forest_' created in the last round will not be subject to annotation processing. 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hibernate-facts --- 
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] Copying 3 resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hibernate-facts --- 
[WARNING] File encoding has not been set, using platform encoding Cp1250, i.e. build is platform dependent! 
[INFO] Compiling 52 source files to D:\wrk\vladmihalcea\vladmihalcea.wordpress.com\hibernate-facts\target\classes 
[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] D:\wrk\vladmihalcea\vladmihalcea.wordpress.com\hibernate-facts\target\classes\com\vladmihalcea\hibernate\model\store\Version_.java:[8,16] error: duplicate class: com.vladmihalcea.hibernate.model.store.Version_ 

元模型类生成两次:

D:\wrk\vladmihalcea\vladmihalcea.wordpress.com\hibernate-facts\target\classes\com\vladmihalcea\hibernate\model\bag\Child_.java 
D:\wrk\vladmihalcea\vladmihalcea.wordpress.com\hibernate-facts\target\generated-sources\java\com\vladmihalcea\hibernate\model\bag\Child_.java 

你知道任何可能的修复吗?

回答

1

我设法得到它的工作是这样的:

<profiles> 
    <profile> 
     <id>jdk16</id> 
     <activation> 
      <jdk>1.6</jdk> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.bsc.maven</groupId> 
        <artifactId>maven-processor-plugin</artifactId> 
        <version>2.0.5</version> 
        <executions> 
         <execution> 
          <id>process</id> 
          <goals> 
           <goal>process</goal> 
          </goals> 
          <phase>generate-sources</phase> 
          <configuration> 
           <outputDirectory>target/generated-sources/java/</outputDirectory> 
           <processors> 
            <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor 
            </processor> 
           </processors> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
    <profile> 
     <id>default</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <configuration> 
         <compilerArguments> 
          <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> 
         </compilerArguments> 
        </configuration> 
        <executions> 
         <execution> 
          <id>process</id> 
          <phase>generate-sources</phase> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 

Maven的处理器插件为JDK 1.6激活,而默认情况下它是Maven的编译器插件应用JPA元模型后处理。

相关问题