No plugin found for prefix 'spring-boot' ...的问题解决方法

我在出初学spring boot时,用idea启动项目没问题,但是用maven启动项目时报错信息如下: 

[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:\Users\Administrator.m2\repository), alimaven (http:// 

maven.aliyun.com/nexus/content/groups/public/)] -> [Help 1] 

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 

[ERROR] Re-run Maven using the -X switch to enable full debug logging. 

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please rea d the following articles: 

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException。 

国类论坛关于此问题的讨论甚少,之后在国外IT论坛StrackOverflow上找到了解决方法,主要有三种原因: 

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.

大致意思就是: 

在命令行运行 mvn spring-boot:run 时,一定要确保你是在包含了该pom.xml的路径下,不然就会出现 No plugin found for prefix 'spring-boot' in the current project and in the plugin groups 这种错误。

我就是这个原因,然后到了所含pom.xml的目录下运行mvn spring-boot:run 就顺利启动了。

现在spring boot报错在国内论坛不太容易找到答案,建议大家多用Google,多看外国论坛,英语不好没关系,用百度翻译慢慢看,不要怕,这是成为优秀程序员的必经之路。

猜你喜欢

转载自nethub2.iteye.com/blog/2354442