Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repac...

springboot项目有多个模块,在项目编译时报如下错误:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage (repackage) on project xxx: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates [xxx.xxxx.Class] -> [Help 1]
[ERROR] 

原因是项目的根pom.xml中配置了build:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <!-- 指定resources插件处理哪个目录下的资源文件 -->
                <directory>src/main/resources</directory>
                <!-- 打开资源过滤功能 -->
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

而项目中,不是所有的模块都是可以打包成可运行的JAR包,故引发了报错。
解决方案是,在编译报错的模块pom.xml中配置build:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

再次编译则可顺利完成编译。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容