无法获取 QueryDsl/APT 来生成 Q 类 [英] Can't get QueryDsl / APT to generate Q classes
问题描述
我正在尝试在新的 Spring 项目中使用 QueryDsl.我是 QueryDsl 的新手,对 maven 和 Spring 也很陌生,所以我可能缺少一些相当基本的东西,但我无法让 QueryDsl/maven-apt-plugin 生成我的 Q 类.Querydsl 参考使听起来如此简单;我想我完全按照它说的做了:
I'm trying to use QueryDsl in a new Spring project. I'm new to QueryDsl, and pretty new to maven and Spring, so I may be missing something fairly basic, but I can't get QueryDsl / maven-apt-plugin to generate my Q classes. The Querydsl reference makes sound so easy; I think I did exactly what it said:
我配置了 pom.xml:
I configured pom.xml with:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
和:
<repository>
<id>QUERYDSL</id>
<url>http://source.mysema.com/maven2/releases</url>
<layout>default</layout>
</repository>
和:
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
我在那个项目中有两个@Entity.
I have two @Entity's in that project.
mvn clean install 不会产生任何输出到 target/generated-sources/java/
mvn clean install does not result in any output to target/generated-sources/java/
我错过了什么?
我试过 mvn apt:process,结果是:
I tried mvn apt:process, and it results in:
[ERROR] Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
有什么建议吗?
谢谢!
推荐答案
好的,我明白了.我不明白(我是 Maven 菜鸟),但这是有效的:在父 pom.xml 中,我有
OK, I got it. I don't understand it (I'm a Maven noob), but here's what worked: In the parent pom.xml, I have
<build>
<pluginManagement>
<plugins>
the maven-apt-plugin definition shown above
</plugin>
<pluginManagement>
</build>
在项目的 POM 中我有:
and in the project's POM I have:
<build>
<plugins>
the **exact same** maven-apt-plugin definition shown above
</plugin>
</build>
在 http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html
这篇关于无法获取 QueryDsl/APT 来生成 Q 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!