maven-plugin - apt maven 插件无法生成 Q 类

标签 maven-plugin m2eclipse apt querydsl

我正在修复一个使用 Querydsl apt 的遗留项目。出于某种原因,apt-maven-plugin开始失败。我发现的唯一解决方法是使用另一个自我 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;

配置 m2e 的一些细节 - Eclipse 的 Maven 集成 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>

最佳答案

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

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

现在,如果 CLI 确实有效,您是否尝试过安装 m2e-apt?它将使注释处理成为 Eclipse 增量构建过程的一部分。见 https://github.com/jbosstools/m2e-apt/更多细节。

关于maven-plugin - apt maven 插件无法生成 Q 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15833988/

相关文章:

scala - 自定义Maven插件上的分类器等效

java - “Force update of snapshots/releases” - 这危险吗?

java - 在 Maven 构建阶段更新 jsp 脚本标签

Maven 构建失败 - 找不到插件

ubuntu - 坚持使用 apt --fix-broken install (libc6 :amd64 package post-installation)

web-services - apt vs wsgen vs wsimport . 关于何时使用什么以及为什么不使用另一个的困惑

maven - 创建 Maven 报告插件

java - 为什么 M2Eclipse 在 mvn 命令行没有时提示缺少工件?

java - 为什么 Maven 正在查找错误的 repo 协议(protocol)?

linux - 如何在不将所有软件包升级到 debian wheezy 的情况下强制 debian squeeze 使用 debian wheezy 中的 libqt4-dev?