0

我有一个在 Eclipse 中开发的 JavaEE Dynamic WEB 项目。

当我通过 Eclipse 编辑 java 类,然后在终端中启动一个“mvn 包”来创建 war 文件时,一切正常。

当我以完全相同的方式修改 java 类但在终端中使用 vim 并启动“mvn 命令”时,编译项目时返回错误:

org.apache.maven.lifecycle.LifecycleExecutionException: Fatal error compiling
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:683)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.codehaus.plexus.compiler.CompilerException: tools.jar not found: /usr/lib/jvm/java-7-openjdk-i386/jre/../lib/tools.jar
    at org.codehaus.plexus.compiler.javac.JavacCompiler.createJavacClass(JavacCompiler.java:987)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.getJavacClass(JavacCompiler.java:944)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:520)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:167)
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678)
    ... 20 more

修改源代码时 Eclipse 执行了哪些操作,而我通过 vim 修改代码时不执行哪些操作?

4

1 回答 1

0

这不是编辑器的问题。

当您运行 Maven 时,您的环境设置会选择两个不同的 Java 实例。错误消息表明您使用的是 JRE 而不是 JDK,解释了代码无法编译的原因。看:

于 2015-12-22T19:00:58.247 回答