Spring Boot jar 包执行报 no main manifest attribute 错误

Spring Boot Maven About 723 words

具体错误

在使用java -jar xxx.jar命令执行打包好的Spring Boot项目,无法运行,抛出以下错误:

no main manifest attribute, in target/xxx.jar

错误分析

jar包是使用mvn clean package打包而成的。

最主要原因:项目是微服务项目,使用Maven构建,由统一的父pom管理Spring Boot和其他依赖的版本,子工程中不再继承自spring-boot-starter-parent

解决方法一

spring-boot-maven-plugin插件中,添加执行步骤repackage即可。

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

解决方法二

可执行spring-boot:repackageMaven命令。

mvn package spring-boot:repackage
Views: 3,091 · Posted: 2022-09-21

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh