2012-05-24 70 views
2

我想在新的Spring项目中使用QueryDsl。我是QueryDsl的新手,对于Maven和Spring来说很新颖,所以我可能会错过一些相当基本的东西,但我无法获得QueryDsl/maven-apt-plugin来生成我的Q类。 Querydsl参考使声音变得如此简单;我觉得我做什么它说:无法获得QueryDsl/APT生成Q类

我配置的pom.xml有:

<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> 

我有两个@实体在那个项目中。

MVN干净的安装不会导致任何输出目标/生成的来源/ JAVA/

我缺少什么?

我试图MVN贴切:过程,它会导致:

[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) 

有什么建议?

谢谢!

回答

1

您正在直接调用目标,但配置是特定于执行的。所以要么通过标准的maven生命周期来使用apt,要么一般地进行配置。

+0

蒂莫的指示,不应该 “MVN干净安装” 工作?是否还需要其他配置?谢谢! – smendola

+0

mvn clean install应该可以工作,build/plugins/plugin部分是必需的 –

2

好的,我明白了。 我不明白它(我是一个Maven的小白),但这里的什么工作: 在父pom.xml中,我有

<build> 
    <pluginManagement> 
    <plugins> 
     the maven-apt-plugin definition shown above 
    </plugin> 
    <pluginManagement> 
</build> 

,并在项目的POM,我有:

<build> 
    <plugins> 
     the **exact same** maven-apt-plugin definition shown above 
    </plugin> 
</build> 

没有< pluginManagement>水平betweeen <构建>和<插件>,以下为http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html

+0

好吧,现在我明白了。顺便说一句,没有必要重复项目POM中的整个插件定义,只需要groupId和artifactId就足够了。 – smendola