700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class

解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class

时间:2022-02-19 11:11:55

相关推荐

解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class

springboot maven 多模块项目打包的时候某个被依赖的模块报错

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.3.RELEASE:

repackage (repackage) on project **-client: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.3.RELEASE:repackage failed:

Unable to find main class -> [Help 1]

这个被依赖的**-client模块并不需要有main类,解决方法是修改父pom.xml

原来的父pom.xml中的标签内容为

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

将父pom.xml中的标签内容改为

<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.3</version><configuration><source>1.8</source><target>1.8</target><fork>true</fork><verbose>true</verbose><encoding>UTF-8</encoding><meminitial>256m</meminitial><maxmem>1024m</maxmem></configuration></plugin></plugins></build>

原因可以参考springboot官网

https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html#build-tool-plugins-maven-packaging

Once spring-boot-maven-plugin has been included in your pom.xml,

it automatically tries to rewrite archives to make them executable by using the spring-boot:repackage goal.

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