繁体   English   中英

QueryDSL maven设置项目

[英]QueryDSL maven set up project

我已按照本文档http://www.querydsl.com/static/querydsl/2.1.0/reference/html/ch02s02.html中描述的说明进行操作

之后,在我的Eclipse中,我出现了以下错误:

Plugin execution not covered by lifecycle configuration: com.mysema.maven:maven-apt-plugin:1.0:process (execution: default, phase: generate-sources)    pom.xml /projectname    line 266    Maven Project Build Lifecycle Mapping Problem

另外,按照QueryDSL文档中的建议,我已经执行了

mvn eclipse:eclipse

为了将target/generated-sources/java作为源文件夹包括在内,现在我有很多警告:

在此处输入图片说明

所以我的问题是:

  1. 通过在我的pom.xml中添加以下内容来解决Plugin execution错误的正确方法:

     <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId> com.mysema.maven </groupId> <artifactId> maven-apt-plugin </artifactId> <versionRange> [1.0,) </versionRange> <goals> <goal>process</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> 
  2. 有没有一种更好的方法可以在不执行mvn eclipse:eclipse情况下将target/generated-sources/java包含为源文件夹?

生成源的正确目标是: mvn generate-sources

这将在编译之前创建QueryDSL查询。

另外,您正在寻找的文档是QueryDSL 2.x版本的。

检查最新版本! http://www.querydsl.com/static/querydsl/4.0.7/reference/html_single/

我通过添加以下插件解决了这些问题:

            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <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>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM