java - Java - maven apt获取mysema插件

我在pom.xml中添加了以下代码段,但是,在Eclipse中,执行错误:


Plugin execution not covered by lifecycle configuration: com.mysema.maven:maven-apt-plugin:1.0.3:process (execution: default, phase: generate-sources)



不过,当我从命令行运行mvn clean安装时,它工作正常。


<build>


 <plugins>


 <plugin>


 <groupId>com.mysema.maven</groupId>


 <artifactId>maven-apt-plugin</artifactId>


 <version>1.0.3</version>


 <executions>


 <execution>


 <goals>


 <goal>process</goal>


 </goals>


 <phase>generate-sources</phase>


 <configuration>


 <outputDirectory>${project.basedir}/target/generated-sources/java</outputDirectory>


 <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>


 <processors>


 <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>


 </processors>


 <showWarnings>true</showWarnings>


 </configuration>


 </execution>


 </executions>


 </plugin>



从命令行运行后,它的生成查询dsl类(QClasses ),但是,从Eclipse中不会生成它们。

另外,当我从Eclipse运行应用程序时,它给出以下错误:


Caused by: java.lang.ClassNotFoundException: xxx.QClass



Eclipse Maven插件有问题? 如何解决此问题?

时间:

如果你只需要从JPA实体类生成Q类,另一个可能的解决方案是使用querydsl apt的分类器,如下所示:


<dependency>


 <groupId>com.querydsl</groupId>


 <artifactId>querydsl-apt</artifactId>


 <version>${querydsl.version}</version>


 <classifier>jpa</classifier>


</dependency>



在这种情况下,你根本不需要手动apt-maven插件构建配置。

这是一个相当古老的插件版本,可能就是它没有被覆盖的原因。请到这里更新,显示的配置https://github.com/mysema/apt-maven-plugin

如果与M2E一起使用请使用以下内容


<plugin>


 <groupId>com.mysema.maven</groupId>


 <artifactId>apt-maven-plugin</artifactId>


 <version>1.1.1</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>


 <dependencies>


 <dependency>


 <groupId>com.mysema.querydsl</groupId>


 <artifactId>querydsl-apt</artifactId>


 <version>3.6.7</version>


 </dependency>


 <dependency>


 <groupId>com.mysema.querydsl</groupId>


 <artifactId>querydsl-jpa</artifactId>


 <classifier>apt</classifier>


 <version>3.6.7</version>


 </dependency>


 </dependencies>


 </plugin>



...