apt maven插件无法生成Q类

时间:2013-04-05 12:27:48

标签: maven-plugin m2eclipse apt querydsl

我正在修复使用Querydsl apt的遗留项目。出于某种原因,apt-maven-plugin开始失败。我找到的唯一解决方法是使用alter ego maven-processor-plugin

我重新安装了maven,eclipse和M2E并没有取得多大成功。 maven-apt-plugin无法在/ 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;

config m2e的一些细节 - Eclipse的Maven Integration 1.2.0.20120903-1050 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e

java版“1.7.0_15” Java(TM)SE运行时环境(版本1.7.0_15-b03) Java HotSpot(TM)64位服务器VM(内置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 个答案:

答案 0 :(得分:2)

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

如果没有,它很可能也无法在日食中构建。

现在如果CLI真的有用,你试过安装m2e-apt吗?它将使注释处理成为eclipse增量构建过程的一部分。有关详细信息,请参阅https://github.com/jbosstools/m2e-apt/

答案 1 :(得分:1)

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