最近在使用spring-boot整合多模塊,但是在父pom中打包maven install時總會報錯:Failed to execute goal org.springframework.boot:spring-boot-maven-plugin,導致錯誤的原因是父pom.xml中引入了如下配置:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
這里引入了spring-boot-maven-plugin,打包時會去掃描項目main方法入口,也就是說引入該配置,你就必須在項目src/main/java/下創建一個spring-boot啟動類:
import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
主意:入口類上一定要加上注解@SpringBootApplication
解決方案:
1. 添加spring-boot啟動類。
2. 將pom.xml中的spring-boot-maven-plugin相關配置注釋掉
3. pom.xml中spring-boot-maven-plugin相關配置修改為普通的maven--plugin配置即可。
