關於Springboot打包錯誤的問題 | Failed to execute goal org.springframework.boot:spring-boot-maven-plugin


 最近在使用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配置即可。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM