代码之家  ›  专栏  ›  技术社区  ›  mahery rafara

apt-maven插件无法生成Q类

  •  4
  • mahery rafara  · 技术社区  · 11 年前

    我正在修复一个使用Querydsl-apt的遗留项目 apt-maven-plugin 开始失败。我找到的唯一解决办法是使用另一个自我 maven-processor-plugin .

    我重新安装了maven、eclipse和M2E,但收效甚微。maven apt插件无法在/target/generated sources/metamodel下创建Q类。

    编辑:从maven添加调试

    [DEBUG] Configuring mojo com.mysema.maven:apt-maven-plugin:1.0.8:process from pl
    ugin realm ClassRealm[plugin>com.mysema.maven:apt-maven-plugin:1.0.8, parent: su
    n.misc.Launcher$AppClassLoader@6d9bf996]
    [DEBUG] Configuring mojo 'com.mysema.maven:apt-maven-plugin:1.0.8:process' with
    basic configurator -->
    [DEBUG]   (s) logOnlyOnError = true
    [DEBUG]   (s) outputDirectory = C:\DEV\myproject\mainstuff\mainstuff-jpa\target\generate
    d-sources\metamodel
    [DEBUG]   (s) pluginArtifacts = [com.mysema.maven:apt-maven-plugin:maven-plugin:
    1.0.8:, org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile, org.codehaus.ple
    xus:plexus-utils:jar:1.5.8:compile, backport-util-concurrent:backport-util-concu
    rrent:jar:3.1:compile, org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
    , junit:junit:jar:3.8.1:compile]
    [DEBUG]   (s) processor = com.mysema.query.apt.jpa.JPAAnnotationProcessor
    [DEBUG]   (s) project = MavenProject: com.yreham.mainstuff:mainstuff-jpa:1.0
     @ C:\DEV\myproject\mainstuff\mainstuff-jpa\pom.xml
    [DEBUG]   (s) sourceEncoding = ISO-8859-1
    [DEBUG] -- end configuration --
    [DEBUG] Using build context: org.sonatype.plexus.build.incremental.DefaultBuildC
    ontext@27bb2f11
    [ERROR] C:\DEV\myproject\mainstuff\mainstuff-jpa\src\main\java\com\yreham\mainstuff\j
    pa\queries\InstancesQuery.java:40: error: cannot find symbol
    import com.yreham.mainstuff.jpa.entity.QCIEntity;
    

    配置m2e-Eclipse的Maven集成的一些细节1.2.0.20120903-1050 org.Eclipse.m2e.feature.group Eclipse.org-m2e

    java版本“1.7.0_15” Java(TM)SE运行时环境(内部版本1.7.0_15-b03) Java HotSpot(TM)64位服务器虚拟机(内部版本23.7-b01,混合模式)

    (目标版本是Java 1.6)

    这是旧的pom XML

    <plugin>
    <groupId>com.mysema.maven</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.0.8</version>
    <executions>
     <execution>
       <goals>
          <goal>process</goal>
       </goals>
      <configuration>
       <outputDirectory>${apt.target.dir}</outputDirectory>
       processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
       <logOnlyOnError>true</logOnlyOnError>
       </configuration>
      </execution>
     </executions>
    </plugin>
    

    带有bsc插件的新POM

    <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>${apt.target.dir}</outputDirectory>
        <processors>
          <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
        </processors>                  
      </configuration>
      </execution>
     </executions> 
     <dependencies> 
      <dependency> 
        <groupId>org.hibernate</groupId> 
          <artifactId>hibernate-jpamodelgen</artifactId> 
           <version>1.2.0.Final</version> 
           </dependency> 
       </dependencies> 
    </plugin>
    
    2 回复  |  直到 11 年前
        1
  •  2
  •   Fred Bricon    11 年前

    您的项目是在命令行中构建的吗?

    如果不这样做,它很可能也无法在eclipse中构建。

    现在,如果CLI真的能工作,你试过安装m2e apt吗?它将使注释处理成为eclipse增量构建过程的一部分。看见 https://github.com/jbosstools/m2e-apt/ 了解更多详细信息。

        2
  •  1
  •   mahery rafara    11 年前

    原来是JPA配置问题。我没有看到它在Querydsl上面使用了Hibernate层。 由于我们转向了Eclipse J2EE版本并添加了M2E WTP http://www.eclipse.org/m2e-wtp/ ,jpa模块已正确重新配置。