繁体   English   中英

Eclipse Maven构建/插件问题

[英]Eclipse Maven Build/Plugin Issue

重新安装了Eclipse 4.9,并且无法再在Eclipse中构建Java项目(仍然可以从命令行构建)。

控制台输出并没有给我带来太多...只是抱怨插件...

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myprojectcommon: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myprojectcommon: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:862)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

我正在带有JDK 1.8_191的OSX High Sierra上运行Eclipse 4.9。 Maven版本是3.5.4,并且Eclipse配置为使用此外部Maven。 设置了JAVA_HOME和M2_HOME(尽管我认为OSX不需要它们)。 我尝试构建现有的工作区,并将该项目导入到一个新的工作区中。

这里有点机智...任何帮助将不胜感激。

编辑1:然后在Eclipse中使用终端,它不能识别mvn命令,也看不到任何系统变量,例如M2_HOME。 Eclipse本身已配置为使用我的外部Maven安装,但是我也尝试使用嵌入式。 在这两种情况下,Eclipse Terminal均无法识别mvn。

尝试查找和删除.m2/repository本地存储库。 应该解决问题!

如果使用的是Java 8,请在pom.xml中尝试添加以下内容:

<properties>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>

或在插件中配置:

     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>your maven compiler plugin version</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin> 

https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

修复:需要从命令行启动Eclipse才能拾取PATH和其他Env Vars

脚步:

  1. 创建了一个名为eclipseLauncher的新脚本,并使其可执行(chmod 755)

     #!/bin/bash /Applications/eclipse/jee-2018-09/Eclipse.app/Contents/MacOS/eclipse & 
  2. 将脚本转换为应用程序:

    一种。 创建一个指向启动脚本的AppleScript(另存为.app类型)…

     do shell script "open /Applications/eclipse/scripts/eclipseLauncher" 

    然后可以将该应用程序移至扩展坞并从那里执行

注意:该应用程序执行脚本,而不是直接发出命令。 当我只是从应用程序中运行命令时,启动Eclipse后无法关闭终端窗口。 只有调用脚本,我才能使它按我想要的方式工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM