3

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:

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> 

and:

<repository> <id>QUERYDSL</id> <url>http://source.mysema.com/maven2/releases</url> <layout>default</layout> </repository> 

and:

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

I have two @Entity's in that project.

mvn clean install does not result in any output to target/generated-sources/java/

What am I missing?

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) 

Any suggestions?

Thanks!

2 Answers 2

3

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> 

and in the project's POM I have:

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

without the <pluginManagement> level betweeen <build> and <plugins>, following the instructions at http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html

Sign up to request clarification or add additional context in comments.

1 Comment

OK, now I get it. BTW, it's not necessary to repeat the entire plugin definition in the project POM, just the groupId and artifactId are sufficient.
1

You are calling the goal directly, but the configuration is execution specific. So either use apt via the standard maven lifecycle or make the configuration general.

2 Comments

Timo, shouldn't "mvn clean install" work? Is there some other configuration I need to make? thanks!
mvn clean install should work, the build/plugins/plugin part is necessary

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.