maven打包spring boot多模块项目提示没有主清单文件

本文介绍了Spring Boot项目在打包时遇到没有主清单文件的问题,以及如何通过配置maven的spring-boot-maven-plugin插件来解决这个问题。关键在于设置`<mainClass>`标签,并使用`<goal>repackage</goal>`目标重新打包,确保应用可以被命令行执行。
摘要由CSDN通过智能技术生成

项目打包运行提示没有主清单文件:在这里插入图片描述
看一看 spring-boot-starter-parent 中的配置:
spring-boot-starter-parent 中maven插件的配置如下:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>${start-class}</mainClass>
    </configuration>
</plugin>

这里配置了主类信息以及一个重要的标签,对repackage的描述如下:
Repackages existing JAR and WAR archives so that they can be executed from the command line using java -jar.
解决:

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

或:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.0.RELEASE</version>
    <configuration>
        <mainClass>com.cn.geostar.api.MetaxApiApplication</mainClass>
    </configuration>
    <executions>
        <execution>
            <id>repackage</id>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值