java Maven apt-get-plugin for mysema
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17865691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven apt-get-plugin for mysema
提问by Arry
I have added following snippet in my pom.xml, but in eclipse the execution part is error saying:
我在我的 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)
Though when I am running mvn clean install from command line it is working properly then.
虽然当我从命令行运行 mvn clean install 时,它可以正常工作。
<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.
从命令行运行后,它会生成查询 dsl 类(QClasses),但从 eclipse 中它不会生成它们。
Also, when I am running my application from eclipse, it gives following error:
此外,当我从 Eclipse 运行我的应用程序时,它会出现以下错误:
Caused by: java.lang.ClassNotFoundException: xxx.QClass
Is there some problem with eclipse maven plugin? How can I resolve this?
eclipse maven 插件有问题吗?我该如何解决这个问题?
回答by lpandzic
Another possible solution, if you only need to generate Q classes from JPA entity classes, is to use the classifier for querydsl-apt like:
另一种可能的解决方案,如果您只需要从 JPA 实体类生成 Q 类,则使用分类器进行 querydsl-apt 如下:
<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.
在这种情况下,您根本不需要手动 apt-maven-plugin 构建配置。
回答by Timo Westk?mper
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
这是插件的一个相当老的版本,可能这就是它没有被覆盖的原因。请更新到此处显示的配置https://github.com/mysema/apt-maven-plugin
回答by Tobi Nonymous
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.
这是您在 eclipse 中经常会看到的错误。基本上,Eclipse 尝试将插件与 m2e 连接器匹配。如果由于您没有安装合适的连接器而未能这样做,则会出现此错误。
Resolving it is quite straitforward: Hover your mouse over the error. You are presented with 3 possible quick fixes, like this:
解决它非常简单:将鼠标悬停在错误上。您会看到 3 种可能的快速修复,如下所示:
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.
- 发现新的 m2e 连接器:可能是最明智的连接器:寻找并安装 m2e 连接器。这解决了您的 eclipse 安装问题(对于此特定插件)
- 在 [...] Eclipse 首选项中将目标 FOOBAR 标记为已忽略:这会在本地 Eclipse 安装中设置首选项以忽略 Eclipse 未找到此特定插件的 m2e 连接器
- 在 pom.xml [...] 中永久标记目标 [...]:这将在项目的 pom.xml 中引入一个配置片段,以忽略 eclipse 找不到 m2e 连接器。
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.
如果您正在使用的插件没有 m2e 连接器,您将要忽略这个问题,因为它非常特定于 Eclipse。尽管如此,您的 maven 构建仍会运行(例如,通过命令行),并且当您配置 Eclipse 以忽略该插件时,Eclipse maven 插件也会很好地构建您的项目。如果您想与您的团队共享配置,或者有不同的 eclipse 安装,请将配置添加到您的 pom.xml 文件中。如果您不想让 IDE 特定设置污染 pom(就像我一样),请使用 eclipse 首选项。
Here is some more detail about this issue: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
以下是有关此问题的更多详细信息:https: //www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
回答by prit kalra
Use the following if using with m2e
如果与 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>
回答by Mowrya K B P
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:
是的 - 不幸的是,这是一个 Eclipse 问题 - 因为您将 Eclipse 指向 JDK - 这很好,但是 Eclipse 本身是一个 Java 应用程序,它也可以在 JVM 中运行。它运行在 JRE 而不是 JDK 中。解决这个问题的方法是 - 在你的 eclipse.ini (或 STS.ini - 如果你使用 Eclipse STS) - 你添加第一行:
-vm
C:\Java\jdk1.8.0_60\bin\javaw.exe
-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
如果您使用的是 Windows,那就是。如果您使用的是 Linux 或 Mac - 您基本上必须在那里使用正确的路径。希望能帮助到你。干杯,欧根。 https://github.com/eugenp/tutorials/issues/247