简体   繁体   English

未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile)

[英]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile)

I know this is a duplicate question but the answers on other topics didn't help me.我知道这是一个重复的问题,但其他主题的答案对我没有帮助。

I'm using Eclipse Photon, Java Version:10, I've set jdk/jre versions on 10 in eclipse and pom.xml file. I'm using Eclipse Photon, Java Version:10, I've set jdk/jre versions on 10 in eclipse and pom.xml file. I've changed eclipse.ini file:我已经更改了 eclipse.ini 文件:

-Dosgi.requiredJavaVersion=10 (it was set to 1.8) -Dosgi.requiredJavaVersion=10(设置为 1.8)

and also I've added plugin in my pom.xml:我还在我的 pom.xml 中添加了插件:

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

Nothing helped.没有任何帮助。 This is my pom.xml:这是我的 pom.xml:

<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>com.luv2code</groupId>
<artifactId>spring-security-demo-06-user-roles</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>spring-security-demo</name>

<properties>

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

<dependencies>

    <!-- Spring Security -->
    <!-- Spring Security WEB -->
    <!-- Spring Security taglibs -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>5.1.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>5.1.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>5.1.1.RELEASE</version>
    </dependency>


    <!-- Spring MVC support -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.1.2.RELEASE</version>
    </dependency>


    <!-- Servlet, JSP and JSTL support -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

</dependencies>


<!-- TO DO: Add support for Maven WAR Plugin -->
<build>
    <finalName>spring-security-demo</finalName>

    <pluginManagement>
        <plugins>
            <plugin>
                <!--  Add Maven coordinates forL maven-war-plugin -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

The dependencies aren't being read in class files and also I've tried deleting.m2 repository and starting Eclipse and doing the: Maven->Clean, Maven->install, and than Maven->update project. class 文件中未读取依赖项,并且我尝试删除.m2 存储库并启动 Eclipse 并执行:Maven-> Clean、Maven-> install 和 Maven-> update 项目。 Nothing helped.没有任何帮助。 I'm really stuck here for about 2-3 hours now.我现在真的被困在这里大约2-3个小时。

Note: in Windows->Preferences->installed JRE's the jre10 was marked with the tick.注意:在 Windows->Preferences->installed JRE's 中,jre10 被标记为勾号。 I changed it to mark the jdk10.我将其更改为标记jdk10。 but still error:但仍然错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project spring-security-demo-06-user-roles: Compilation failure

Everything was working fine until I added the dependency of: spring-security-taglibs.一切正常,直到我添加了以下依赖项:spring-security-taglibs。

Deleting the dependency doesn't do anything aswell.删除依赖项也不做任何事情。

Check properly settings with version of your project in eclipse and version of your runner for maven.使用 eclipse 中的项目版本和 maven 的运行器版本正确检查设置。


I have reproduced the same issue with maven-compiler plugin , but using version 3.8.1:我用maven-compiler plugin重现了同样的问题,但使用版本 3.8.1:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project testName: Fatal error compiling

My POM was:我的 POM 是:

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

To clarify:澄清:

in project I'm using Java 11 and IntelijIDEA (but logic I think the same for eclipse).在项目中,我使用的是 Java 11 和 IntelijIDEA(但我认为 Eclipse 的逻辑也是如此)。 So I'm using maven lifecycle phases fine only if my version of project (check properly Project Structure -> Project Settings) corresponds to version of maven runner.因此,仅当我的项目版本(正确检查项目结构 - > 项目设置)对应于 maven runner 的版本时,我才可以使用 maven 生命周期阶段。

在此处输入图片说明

Eg if version of runner is for java 8, but project settings are for Java 11 then I'm getting this error.例如,如果 runner 版本适用于 Java 8,但项目设置适用于 Java 11,那么我会收到此错误。 If I have the same for both then I don't have any problems.如果我对两者都相同,那么我没有任何问题。


And I highly recommend to check all settings for maven and the whole project.我强烈建议检查 Maven 和整个项目的所有设置。 It helps to avoid the issues in the future.它有助于避免将来出现问题。 Deleting folder for maven is as alternative solution, but it must be last thing that you need to do.删除 maven 的文件夹是一种替代解决方案,但它必须是您需要做的最后一件事。

It started working Automagically .它开始自动工作。 FIX : delete .m2 repository.修复:删除 .m2 存储库。

I did that yesterday but it didn't help, today somehow, deleting the .m2 repository and updating the project helped !我昨天做了,但它没有帮助,今天不知何故,删除 .m2 存储库并更新项目有帮助!

确认,删除 .m2/settings.xml 指向的整个本地存储库,通常是 .m2/repository

I updated my Java SDK to 11.9 and reloaded the project.我将 Java SDK 更新为 11.9 并重新加载了项目。 With this I solved my problem.有了这个,我解决了我的问题。

I had the same issue, it was because the Spring Boot project was using Java 11 but my %JAVA_HOME% variable was pointing to Java 8 home directory.我遇到了同样的问题,这是因为 Spring 引导项目正在使用 Java 11 但我的 %JAVA_HOME% 变量指向 ZD52387880E1EA22817A72D3759213819 主目录。 I resolved the issue by changing the path to %JAVA_HOME% variable.我通过更改 %JAVA_HOME% 变量的路径解决了这个问题。

暂无
暂无

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

相关问题 无法执行目标 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) 无法执行目标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 “无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)” - "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)" 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.3:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project 无法在项目 dbproxy 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile): - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project dbproxy: 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2。 3.2:在项目aopencommon上编译(默认编译) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2. 3.2:compile (default-compile) on project aopencommon 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project 无法执行目标 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) 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) Java 11:目标org.apache.maven.plugins的执行默认编译:maven-compiler-plugin:3.8.0:编译失败。:NullPointerException - Java 11 : Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile failed.: NullPointerException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM