简体   繁体   English

maven-compiler-plugin 编译失败:3.6.1

[英]Compilation failure for maven-compiler-plugin: 3.6.1

I knew there are a lot of maven-compiler-plugin failure issues posted here.我知道这里发布了很多 maven-compiler-plugin 失败问题。 and I read most of them and tried to resolve my own issue based on the solutions from those posts.我阅读了其中的大部分内容,并尝试根据这些帖子中的解决方案来解决我自己的问题。 But it seemed not working for my case.但这似乎不适用于我的情况。 Here is what I used:这是我使用的:
Maven version: Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T11:06:16-04:00) Maven version: Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T11:06:16-04:00)
Maven home: C:\apps\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin.. Maven 主页:C:\apps\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin..
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files x86)\Java\jdk1.8.0_191\jre Java 版本:1.8.0_191,供应商:Oracle Corporation,运行时:C:\Program Files x86)\Java
Default locale: en_US, platform encoding: Cp1252默认语言环境:en_US,平台编码:Cp1252
OS name: "windows 10", version: "10.0", arch: "x86", family: "windows"操作系统名称:“windows 10”,版本:“10.0”,arch:“x86”,系列:“windows”

the partial pom.xml:部分 pom.xml:

    <build>
        <sourceDirectory>src/main/java/com/xyz/shared</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/shared/**</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

The project was compiled without any issue on my old laptop (a HP zbook).该项目在我的旧笔记本电脑(HP zbook)上编译没有任何问题。 When I run the same project on another laptop (also a zbook of same type exactly) from a command line, like当我从命令行在另一台笔记本电脑(也是相同类型的 zbook)上运行相同的项目时,例如

C:\workspace\xyz\common>mvn -e clean compile C:\workspace\xyz\common>mvn -e clean 编译

it shown the following error msg,它显示了以下错误消息,

[INFO] Compiling 37 source files to C:\workspace\xyz\common\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.833 s
[INFO] Finished at: 2021-01-12T11:00:34-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project common: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project common: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1033)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

here both maven and java are 32 bits.这里 maven 和 java 都是 32 位。 they are the same for the old and new laptops.对于新旧笔记本电脑,它们是相同的。

I also tried to use different versions of the maven-compiler-plugin, but with no luck.我还尝试使用不同版本的 maven-compiler-plugin,但没有运气。

I could not figure out what was wrong.我不知道出了什么问题。

The problem is found.问题找到了。 In the parent maven module's pom.xml, there is a line在父maven模块的pom.xml中有一行

<executable>C:\Program Files (x86)\Java\jdk1.8.0_221\bin\javac.exe</executable>

here the java version is different from the actual verion of java on the computer(jdk1.8.0_191).这里的 java 版本与电脑上 java 的实际版本不同(jdk1.8.0_191)。 Comment the line off or change to the correct java version fix the issue.注释掉该行或更改为正确的 java 版本修复该问题。

暂无
暂无

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

相关问题 编译错误:无法执行 maven-compiler-plugin:2.3.2:compile - COMPILATION ERROR : Failed to execute maven-compiler-plugin:2.3.2:compile 无法执行maven-compiler-plugin:3.6.1:使用java 9时的testCompile - Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9 MAVEN BUILD FAILURE: 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) : Compilation failure - MAVEN BUILD FAILURE: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) : Compilation failure 找不到 maven 编译器插件 - maven-compiler-plugin not found 无法在项目acme模块上执行目标org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile):编译失败: - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project acme-module: Compilation failure: 无法在项目 grpc_hello_server 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile):编译失败 - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project grpc_hello_server: Compilation failure Maven忽略了“ maven-compiler-plugin”要求 - Maven ignores the “maven-compiler-plugin” requirements 使用带有java 1.8和netbeans的maven-compiler-plugin 2.5.1在Java中进行注释的编译错误 - Compilation error for annotations in Java using maven-compiler-plugin 2.5.1 with java 1.8 and netbeans Maven编译器插件错误(maven-compiler-plugin:2.5.1:testCompile) - Maven Compiler Plugin Error (maven-compiler-plugin:2.5.1:testCompile) 父 pom 中的 maven-compiler-plugin - maven-compiler-plugin in parent pom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM