Maven使用spring-data-jpa和querydsl构建问题 [英] Maven build problems with spring-data-jpa and querydsl

查看:382
本文介绍了Maven使用spring-data-jpa和querydsl构建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于spring-data-jpa和QueryDsl的Eclipse Maven项目.

I've got an Eclipse Maven project for spring-data-jpa and QueryDsl.

我似乎对maven-apt-plugin有问题,如果我先进行mvn清理再进行mvn安装,它将尝试处理"引用QueryDsl生成文件的文件,但这些生成文件尚未已构建,因此出现多个找不到符号"错误.

I seem to have a problem with the maven-apt-plugin where if I do a mvn clean followed by a mvn install, it tries to "process" files that reference the QueryDsl generated files, but these generated files have not yet been built so I get multiple "cannot find symbol" errors.

如果然后必须执行另一个mvn安装,则一切正常,因为现在已存在生成的文件.

If then have to do another mvn install, everything is ok as the generated files now exist.

这个maven-apt-plugin是否需要处理项目中的每个文件,还是可以给它指定目录?

Does this maven-apt-plugin need to process every file in my project, or can I give it a specified directory ?

注意:我正在使用JDK6,Eclipse Indigo,M2E 1.0.100

Note: Im using JDK6, Eclipse Indigo, M2E 1.0.100

我的POM是:

<project>
  ....
  <build>
    <plugins>
      <plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>maven-apt-plugin</artifactId>
        <version>1.0.2</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>target/generated-sources</outputDirectory>
              <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ....
</project>

推荐答案

Alex,尝试定义build-helper:

Alex, try to define build-helper:

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

这篇关于Maven使用spring-data-jpa和querydsl构建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆