English 中文(简体)
无法获取查询Dsl / APT 生成 Q 类
原标题:Can t get QueryDsl / APT to generate Q classes

我试图在一个新的 Spring 工程中使用 QueryDsl 。 我新到 QuryDsl, 并且非常新到 maven 和 Spring, 所以我可能错过了相当基本的东西, 但我无法获得 QueryDsl / Maven-apt-plugin 来生成我的 Q 类。 Querydsl 引用听起来很简单; 我认为我做了它所说的:

我配置了 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>

我有两个@Enity在这个项目中。

mvn清洁装置不会导致目标/源/java/

我错过了什么?

我尝试了 mvn appt: process, 结果:

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

有什么建议吗?

谢谢!

问题回答

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>

在项目S POM中,我有:

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

没有 & lt; plutin management> 级别 Betweeen; building> 和 < plutins>, 按照< a href=" http:// mojo.codehaus. org/apt-maven-plugin/plugin- info. html" rel= “ nofollow” > http://mojo.codehaus.org/apt-maven-plutin/plugin-info. html 的指示

您正在直接调用目标, 但配置是具体执行的 。 所以要么通过标准 Maven 生命周期使用 apapplit, 要么使配置常规化 。





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签