【问题标题】:How to say to eclipse-maven-plugin perform from eclipse same actions as mvn from cmd如何说 eclipse-maven-plugin 从 eclipse 执行与 cmd 中的 mvn 相同的操作
【发布时间】:2014-05-15 11:18:37
【问题描述】:

我使用 Eclipse IDE 和 Windows 操作系统开发 java 应用程序。

我有这个问题:从 cmd 我的 maven 任务运行良好,但如果我从 eclipse 调用它 - 我看到 build failure

我想在我的 Eclipse 中使用带有 cmd 配置的 maven。

我做了以下步骤:

C:\>set m2_home
M2_HOME=C:\Program Files\apache\apache-maven-3.1.1

我只想从 Eclipse 执行与 cmd 相同的操作。

你能帮帮我吗?

更新——问题演示

来自 Eclipse:

我这样调用:

结果:

...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.273s
[INFO] Finished at: Thu Apr 03 18:39:58 MSK 2014
[INFO] Final Memory: 91M/782M
...

来自 cmd:

D:\work\ct\ctc-core>mvn clean install
.....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:01.446s
[INFO] Finished at: Thu Apr 03 18:42:48 MSK 2014

更新

如果我在 Eclipse 的 maven 命令中添加 -X

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41.161s
[INFO] Finished at: Thu Apr 03 19:09:16 MSK 2014
[INFO] Final Memory: 91M/752M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.7.4:scr (generate-scr-descriptor) on project ctc-core-import: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.7.4:scr failed: Comparison method violates its general contract! -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.felix:maven-scr-plugin:1.7.4:scr (generate-scr-descriptor) on project ctc-core-import: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.7.4:scr failed: Comparison method violates its general contract!
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.7.4:scr failed: Comparison method violates its general contract!
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeLo(TimSort.java:747)
    at java.util.TimSort.mergeAt(TimSort.java:483)
    at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
    at java.util.TimSort.sort(TimSort.java:223)
    at java.util.TimSort.sort(TimSort.java:173)
    at java.util.Arrays.sort(Arrays.java:659)
    at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:235)
    at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:192)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    ... 21 more

【问题讨论】:

  • 您能否发布更多来自 Eclipse 会话的 Maven 输出?查找以[ERROR] 开头的输出。还可以在 Maven 目标配置中添加 -X 选项,以显示 Maven 在失败时所做的极端细节。
  • @unhillbilly 请阅读更新
  • @unhillbilly 我在使用 java 7 时遇到了这个问题。似乎 ecilpse 使用 java 7。你知道在哪里可以切换我的 java 版本吗?
  • 感谢您使用日志输出更新问题。是的,在使用 JDK 7(或 Android)时,这似乎是兼容性问题stackoverflow.com/a/8417510/55452。您的命令行 Maven 设置是否使用 JDK 6?如果是这样,请在您的 Eclipse 设置中使用 JDK 6(请参阅 Prefs->Java->Installed JREs),并让您的项目使用它(Java Build Path->Libraries)
  • @unhillbilly 真的,我切换了我的 java 版本,它对我有帮助。非常感谢!

标签: java eclipse maven maven-eclipse-plugin


【解决方案1】:

当排序例程遇到不严格满足接口契约的Comparable 实现时,它看起来像是与行为相关的compatibility issue when using JDK 7 (or Android)

如果您的命令行 Maven 设置使用 JDK 6,请在您的 Eclipse 设置中使用 JDK 6(请参阅 Prefs->Java->Installed JREs),并让您的项目使用它(Java Build Path->Libraries)。

对于其他想要回归 JDK 6(不推荐)的人,可以是 obtained here

【讨论】:

    猜你喜欢
    • 2011-04-02
    • 2011-11-16
    • 2013-02-10
    • 1970-01-01
    • 2021-09-09
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多