maven的install报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0

maven的install报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0

1、maven打包报错

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:repackage (default) on project gyc-auth: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:repackage failed: Unable to load the mojo ‘repackage’ in the plugin ‘org.springframework.boot:spring-boot-maven-plugin:3.0.0’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

解决:

在pom.xml添加spring boot的打包版本,如果我们不指定,默认使用最新的spring boot来打包,而最新的打包需要JDK17环境支持(另一个解决办法:本地环境安装JDK17)。

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.2.1.RELEASE</version>
    <executions>
        <execution>
            <id>repackage</id>
            <configuration>
                <excludeDevtools>true</excludeDevtools>
            </configuration>
        </execution>
    </executions>
</plugin>

2、maven指定编译JDK版本

一般不指定会出现的问题:
1、MAVEN默认的编译环境是1.5,JDK1.5版本以上的语法都不支持。

 <build>
        <plugins>
            <!-- 指定JDK编译版本 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <!-- 指定JDK打包版本,要不默认最新spring boot打包,需要JDK17环境 -->

        </plugins>
    </build>
### Maven 构建 Spring Boot 项目时插件执行失败的原因分析 当遇到 `Failed to execute goal` 错误提示时,通常意味着构建过程中的某个阶段未能成功完成。对于特定错误 `failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.4.1` 的情况,可能原因包括但不限于: - 版本兼容性问题:使用的 `spring-boot-maven-plugin` 插件版本与当前项目的依赖库或其他配置不匹配。 - 配置文件缺失或错误:POM 文件中缺少必要的 `<build>` 或者 `<plugins>` 节点定义[^1]。 针对上述提到的情况,在 POM 文件内指定合适的插件版本可以有效解决问题。具体做法如下所示: ```xml <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.3</version> </plugin> </plugins> </build> ``` 另外需要注意的是,如果更改了插件版本后仍然存在相同类型的错误,则可能是由于本地环境设置不当引起的。此时建议清理本地仓库缓存并重新下载所需资源;也可以尝试更新至最新稳定版的 Spring Boot 和其对应的 Maven 插件来获得更好的支持和修复已知漏洞。 关于端口号冲突的问题,可以通过修改应用启动参数的方式改变默认监听地址,从而避开已被占用的8080端口。可以在命令行添加如下选项启动服务: ```bash java -jar your-app.jar --server.port=9090 ``` 或者在 application.properties 中加入相应配置项实现同样的效果: ```properties server.port=9090 ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值