maven打包异常-Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEAS
Posted IT-熊猫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven打包异常-Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEAS相关的知识,希望对你有一定的参考价值。
问题再现
在进行mvn打包的时候出现:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage (repackage) on project service_base: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage failed: Unable to find main class
原因分析
项目里面包含了某些工具类的模块,而工具类模块是没有main启动类,但是父工程的pom文件却引用了 springboot默认打包插件 spring-boot-maven-plugin
, 所以在打包的时候maven会扫描所有的依赖模块,如果发现某个模块下面没有main启动类,就会报错。
解决办法
父工程配置Apache的编译插件
<build>
<plugins>
<!--编译插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
需要打包的工程配置springboot打包插件
<build>
<plugins>
<!-- springboot maven打包-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
问题解决
以上是关于maven打包异常-Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEAS的主要内容,如果未能解决你的问题,请参考以下文章
maven打包异常-Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEAS
maven打包出错: Failed to clean project: Failed to delete
Maven异常_04_Failed to clean project
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0
Spring boot打包报错:Failed to execute goal org.apache.
maven打包错误: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources(代码