mvn编译错误LifecycleExecutionException

时间:2017-12-07 13:40:24

标签: java maven javac

我已将maven添加到我的路径中。当我运行命令mvn -v时,它返回:

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T10:58:13+03:00) 
Maven home: /Users/yarkoni/apache-maven-3.5.2 Java version: 9, vendor: Oracle Corporation 
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home 
Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", 
version: "10.12.6", arch: "x86_64", family: "mac"

据我所知,为了安装我下载并将其添加到我的PATH。 然后我尝试在本地试用他的appEngine app示例:

mvn -Plocal clean appengine:devserver

我收到以下错误:

    [INFO] Compiling 11 source files to /Users/yarkoni/Projects/getting-started-java/bookshelf-standard/2-structured-data/target/bookshelf-standard-2-1.0-SNAPSHOT/WEB-INF/classes An exception has occurred in the compiler (9-internal). 
Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.io.UncheckedIOException: java.nio.file.NotDirectoryException: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.lazy(Locations.java:712)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.isDefault(Locations.java:546)
    at com.sun.tools.javac.file.Locations.isDefaultBootClassPath(Locations.java:126)
    at com.sun.tools.javac.file.BaseFileManager.isDefaultBootClassPath(BaseFileManager.java:204)
    at com.sun.tools.javac.main.Arguments.validate(Arguments.java:479)
    at com.sun.tools.javac.api.JavacTaskImpl.prepareCompiler(JavacTaskImpl.java:168)
    at com.sun.tools.javac.api.JavacTaskImpl.access$000(JavacTaskImpl.java:69)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:96)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
    at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:222)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:943)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    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.MojoExecutor.executeForkedExecutions(MojoExecutor.java:353)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
    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:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    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: java.nio.file.NotDirectoryException: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules
    at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:407)
    at java.base/java.nio.file.Files.newDirectoryStream(Files.java:465)
    at java.base/java.nio.file.Files.list(Files.java:3524)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.systemClasses(Locations.java:665)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.computePath(Locations.java:621)
    at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.lazy(Locations.java:709)     ... 49 more

2 个答案:

答案 0 :(得分:0)

 java.nio.file.NotDirectoryException: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules

似乎/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules不是当前文件系统中的目录,但它应该是。也许某人或某事与您的Java安装有关。您应该确保此路径指向目录或重新安装JDK。

答案 1 :(得分:0)

查看this。似乎maven编译器可以与不同的编译器(例如,容易出错的,plexus等)一起使用,并且这些插件在JDK开发中略有落后。

您有2个选择:

  • 使用JDK 8进行构建
  • 找出所需的配置(例如error prone

希望这对某人有帮助,我仍在调查自己哪种方法更合适。

编辑:我暂时降级了,但是我打算进行调查,一旦完成,我将更新此答案。