Maven apt-get-plugin for mysema

限于喜欢 提交于 2019-12-10 21:10:18

问题


I have added following snippet in my pom.xml, but in eclipse the execution part is error saying:

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

Though when I am running mvn clean install from command line it is working properly then.

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

After running from command line, its generating query dsl classes (QClasses), but from eclipse its not generating them.

Also, when I am running my application from eclipse, it gives following error:

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

Is there some problem with eclipse maven plugin? How can I resolve this?


回答1:


Another possible solution, if you only need to generate Q classes from JPA entity classes, is to use the classifier for querydsl-apt like:

<dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>${querydsl.version}</version>
    <classifier>jpa</classifier>
</dependency>

In that case you don't need manual apt-maven-plugin build configuration at all.




回答2:


This is a quite old version of the plugin and probably that's the reason why it's not covered. Please update to the configuration displayed here https://github.com/mysema/apt-maven-plugin




回答3:


This is an error that you will see very often in eclipse. Basically, Eclipse tries to match a plugin to an m2e connector. If it fails to do so, because you have not installed a suitable connector, you get this error.

Resolving it is quite straitforward: Hover your mouse over the error. You are presented with 3 possible quick fixes, like this:

They have the following effects:

  • Discover new m2e connectors: probably the most sensible one: Look for a m2e connector and install it. This solves the problem for your eclipse installation (for this specific plugin)
  • Mark goal FOOBAR as ignored in [...] Eclipse preferences: This sets a preference within your local Eclipse installation to ignore that Eclipse didn't find a m2e connector for this specific plugin
  • Permanently mark goal [...] in pom.xml [...]: This will introduce a configuration snippet in the pom.xml of the project to ignore that eclipse doesn't find a m2e connector.

If there isn't an m2e connctor for the plugin you're using, you will want to ignore this problem, as it is very Eclipse specific. Your maven build will run nevertheless (e.g. via command line), and when you configure Eclipse to ignore the plugin, the Eclipse maven plugin will build your project fine as well. If you want to share the configuration with your team, or have different eclipse installations, add the configuration to your pom. If you prefer not to have the pom polluted by IDE specific settings (like I do), rather use the eclipse preference.

Here is some more detail about this issue: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html




回答4:


Use the following if using with 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>



回答5:


Yes - it's unfortunately an Eclipse issue - because you're pointing Eclipse to the JDK - which is good, but Eclipse itself is a Java app that also runs in a JVM. And it's running in the JRE instead of the JDK. The way to fix that is - in your eclipse.ini (or STS.ini - if you're using Eclipse STS) - you add this first line:

-vm C:\Java\jdk1.8.0_60\bin\javaw.exe

If you're on Windows that is. If you're on Linux or on the Mac - you'll basically have to use the right path there. Hope it helps. Cheers, Eugen. https://github.com/eugenp/tutorials/issues/247



来源:https://stackoverflow.com/questions/17865691/maven-apt-get-plugin-for-mysema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!