English 中文(简体)
Maven build problems with spring-data-jpa and querydsl
原标题:

I ve got an Eclipse Maven project for spring-data-jpa and 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.

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

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

Note: Im using JDK6, Eclipse Indigo, M2E 1.0.100

My POM is:

<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, 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>
问题回答

Do you get errors or just warnings? You can add the true to reduce the error logging.

This kind of logging is a part of APT, since in the first run before types have been generated, the sources inspection sees references to nonavailable types.

I got many "cannot find symbol" logging (and the processing succeeded), too. It seems to be related with the following issue.

https://github.com/mysema/maven-apt-plugin/issues/2

Fixed by adding the following options.

<logOnlyOnError>true</logOnlyOnError>




相关问题
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 ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签