Unable to find a single main class from the following candidates
Could not find artifact
上面是我犯的两个错误,下面一一解答:
第一个错误的主要原因是:找不到唯一的主启动类;
解决办法是:在使用springboot-maven插件时候没有配置主启动类,而且插件的位置我也放错了,下面图大家看一下吧
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--
1. 这里要指定你的springboot项目的主启动类的全类名
2. 大家不要把这个插件放到父项目的依赖中,哪个项目需要打包,就放到哪个项目的依赖下
-->
<mainClass>com.hhly.InformationApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
第二个错误是:Could not find artifact xxx.jar 我的是找不到common这个jar包
解决方法:因为bookcommerce打包需要去本地仓库找common.jar包,但事先我没有将common放到本地仓库中,导致才会报出这个错误
我们可以在common但pom中,执行maven install的命令,此时发现仓库有这个jar包了。
其实还有更简单的方法:直接在父项目中执行maven install的指定,发现父项目下的子项目全部打包成功。
附上我查询到的资料
Maven异常:Could not find artifact
springboot多模块项目mvn打包遇到的问题 - 存在依赖但却无法发现符号
根本原因是不知道maven install的命令是做什么的 很尴尬
mvn install 将项目打包到本地仓库
希望大家不要在坑中玩耍,太累了#_#