简体   繁体   English

Maven编译错误-无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile

[英]maven compilation error - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile

I am trying to run mvn clean compile test for my automated tests and getting the maven compilation error message. 我正在尝试对自动化测试运行mvn clean compile test ,并获取maven编译错误消息。

I am posting the error message and my pom file here. 我在此处发布错误消息和我的pom文件。

I am using cucumber framework and the java version is 1.8.0_144. 我正在使用Cucumber框架,而Java版本是1.8.0_144。

PS:I am able to run the test manually through my IDE without any error. PS:我能够通过我的IDE没有任何错误手动运行测试。

Can someone guide me on why this is happening? 有人可以指导我为什么会这样吗?

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.913 s
[INFO] Finished at: 2018-06-04T09:13:25+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project CucumberFramework: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project CucumberFramework: 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:976)
    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)
    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)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

POM file: POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>CucumberFramework</groupId>
    <artifactId>CucumberFramework</artifactId>
    <version>1.0-SNAPSHOT</version>


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <fork>true</fork>
                        <!--<executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable>-->
                        <executable>/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home</executable>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.19.1</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
                        <!--<testErrorIgnore>false</testErrorIgnore>IGNORING THIS!!!!!!!!!!!!!!!!!!!!!!!-->
                        <testFailureIgnore>false</testFailureIgnore>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
        </plugins>
    </reporting>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.11.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- Extent Reports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.0.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.26-incubating</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.vimalselvam</groupId>
            <artifactId>cucumber-extentsreport</artifactId>
            <version>2.0.4</version>
        </dependency>
    </dependencies>


</project>

Forked error: 分叉的错误:

caused by: java.lang.RuntimeException: There was an error in the forked process
org.testng.TestNGException:

Cannot find class in classpath: Cucumber.runners.MainRunner
    at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
    at org.testng.xml.XmlClass.init(XmlClass.java:73)
    at org.testng.xml.XmlClass.<init>(XmlClass.java:59)
    at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:556)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
    at org.testng.xml.XMLParser.parse(XMLParser.java:39)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)
    at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)
    at org.testng.xml.Parser.parse(Parser.java:172)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:305)
    at org.testng.TestNG.run(TestNG.java:1036)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281)
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

From your pom: 从您的pom:

<executable>/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home</executable>

That's probably not really your executable . 那可能不是您的可执行文件 I would recommend just removing that line. 我建议只删除该行。

If you really want to hard code your java executable, find where the java binary really is - what you have now looks like a directory, not the binary executable. 如果您确实想对Java可执行文件进行硬编码,请找到Java二进制文件的实际位置-现在看起来像目录,而不是二进制可执行文件。

Also note that in general to find out details about the error, running maven with debug logging on ( mvn -X ) is recommended. 还要注意,通常要查找有关错误的详细信息,建议在调试日志记录为( mvn -X )的情况下运行maven。

please right click on "Maven Dependencies" Build Path, Configure Build Path. 请右键单击“ Maven Dependencies”构建路径,配置构建路径。 From Java build Path on the left menu select "java Compiler" press apply. 从左侧菜单上的Java build Path中选择“ java Compiler”,然后按Apply。 deselect "enabled project specific Settings". 取消选择“启用的项目特定设置”。 then apply and close. 然后申请并关闭。 right click on pom.xml and "Run As 5Maven Install. 右键单击pom.xml,然后选择“以5Maven安装方式运行。

Repeat this process again from first to last but this time Select "Enabled Project Specific Settings" and Apply Close 从头到尾再次重复此过程,但这一次选择“已启用项目特定设置”并应用“关闭”

right click on pom.xml and "Run As 5Maven Install.this time it will install all the plugins with out any problem. 右键单击pom.xml,然后选择“运行为5Maven Install。这一次它将安装所有插件,而不会出现任何问题。

Hope this will answer your question. 希望这能回答您的问题。

This is an irritating error that pops up once in a while , jotting down some steps which help: 这是一个令人不快的错误,有时会弹出,并记下一些有助于执行以下操作的步骤:

Writing answer from eclipse perspective as base logic will remain the same whether done by Intellij or command line 从eclipse角度将答案写为基本逻辑,无论是通过Intellij还是通过命令行完成,都将保持不变

  1. Rt click your project -> Maven -> Update project -> Select Force update -> Click OK Rt单击您的项目-> Maven->更新项目->选择强制更新->单击确定
  2. Under properties tag , add : 在属性标签下,添加:
  <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> 
  1. In some instance , you will start seeing error as we tried force update , saying , failure to transfer X dependency from Y path , resolutions will not be reattempted , bla bla bla 在某些情况下,当我们尝试强制更新时,您将开始看到错误,例如, 无法从Y路径传输X依赖项,将不会重新尝试解决方案,等等。

In such case quickly fix it by cd to .m2/repository folder and run following command : 在这种情况下,请通过cd将其快速修复到.m2 / repository文件夹,然后运行以下命令:

for /r %i in (*.lastUpdated) do del %i
  1. Also , if you have the JDK 8 already set in the class path , you do not need fork tag , try to remove and build the project 另外,如果您已经在类路径中设置了JDK 8,则不需要fork标签,请尝试删除并构建项目

暂无
暂无

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

相关问题 Maven构建错误:无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile - Maven build error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile 在Azure DevOps管道生成上收到此错误“无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” - getting this error “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” on Azure DevOps pipeline build 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:在项目上编译(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project Maven:未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.10.1compile: - Maven: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile Maven 构建编译错误:无法在项目 Maven 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) - Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven Intelij IDEA-无法执行目标org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile - Intelij IDEA - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.1:compile - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile 无法使用 MAVEN 构建并出现错误 - 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile - Unable to Build using MAVEN with ERROR - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM