SpringBoot打包报错Failed to execute goal :spring-boot-maven-plugin:2.1.

时间:2025-04-21 09:14:22

当不希望将SpringBoot打包成独立运行的jar,而只是当做工具jar包时,去掉启动类,打包报错:

Failed to execute goal :spring-boot-maven-plugin:2.1.:repackage (repackage) on project plat-common: Execution repackage of goal :spring-boot-maven-plugin:2.1.:repackage failed: Unable to find main class -> [Help 1]

原因是SpringBoot使用了自动打包插件,会在打包时找项目下的启动程序

解决办法:
    去掉SpringBoot自带的自动打包插件

    使用Apache的打包插件

    <plugin>
        <groupId></groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>