天天看點

No plugin found for prefix spring-boot in the current project and in the plugin groups 異常解決

一. 異常問題

我在intellij idea中通過mvn spring-boot:run指令來啟動springboot項目的時候,結果産生如下圖所示的異常資訊:

異常現象

No plugin found for prefix spring-boot in the current project and in the plugin groups 異常解決
[ERROR] No plugin found for prefix 'spring-boot' in the current 

project and in the plugin groups [org.apache.maven.plugins, 

org.codehaus.mojo] available from the repositories [local (C:\MavenRepository), central 

(https://repo.maven.apache.org/maven2)] -> [Help 1]      

二. 原因分析

産生該問題的原因大緻有如下三種:

1. pom.xml檔案裡少了parent依賴,代碼如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.7.RELEASE</version>
 </parent>      

這種錯誤一般不會存在。

2. 缺少如下代碼:

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>      

3. 運作mvn spring-boot:run 指令時的路徑不對:

If you are running the mvn spring-boot:run from the command line, 

make sure you are in the directory that contains the pom.xml file. 

Otherwise, you will run into the No plugin found for prefix ‘spring-

boot’ in the current project and in the plugin groups error.      

三. 解決辦法