300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > springboot项目进行 mvn install 时报错 repackage failed: Unable to find main class 处理记录

springboot项目进行 mvn install 时报错 repackage failed: Unable to find main class 处理记录

时间:2019-05-22 22:03:08

相关推荐

springboot项目进行 mvn install 时报错 repackage failed: Unable to find main class 处理记录

异常描述:springboot项目进行 mvn install时 报错如下

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.7.RELEASE:repackage (repackage) on project match-service: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.7.RELEASE:repackage failed: Unable to find main class

排查报错原因:

在各模块的pom.xml中均引入了maven 打包插件

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

在插件运行时

需要指定或者继承了spring-boot-starter-parent并且配置需属性,然后插件会自动寻找签名是public static void main(String[] args)的方法… ,

mainClass和statrt-class即程序的入口,即使用了@SpringBootApplication注解且有main方法的启动类,

我这里的原因是,由于没有添加启动类。所以执行mvn install时会报上述异常

解决办法:

添加启动类或者注释掉没有启动类的模块pom中的上述依赖。

附加知识点:

下配置mainClass,指定程序入口。

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>1.5.3.RELEASE</version><configuration><mainClass>com.xx.webapps.api.main.WebappsApiBidMain</mainClass></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin>

Spring Boot Maven Plugin提供了几个目标(goal),我们在标签里配置的repackage对应spring-boot:repackage这个目标。

如果你的pom继承自spring-boot-starter-parent(注意此前提),也可以直接在配置(其实这里的start-class直接对应清单文件里的Start-Class):

<properties><start-class>com.xx.webapps.api.main.WebappsApiBidMain</start-class></properties>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。