Maven-在当前项目和插件组中找不到前缀“spring-boot”的插件

问题描述 投票:0回答:12

我正在尝试构建一个使用 Spring Tools Suite 构建的 springboot 项目。当我执行时出现以下错误

$mvn spring-boot:run

Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 14.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 21.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.032 s
[INFO] Finished at: 2015-06-15T17:46:50-04:00
[INFO] Final Memory: 11M/123M
[INFO] ------------------------------------------------------------------------
[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 (/Users/admin/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [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 read the following articles:
[ERROR] [Help 1]     http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException`
   

这是我的 pom.xml 插件

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <arguments>
                        <argument>--spring.profiles.active=dev</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

我尝试了上面的jhipster插件,错误没有变化。

java spring maven spring-mvc
12个回答
260
投票

如果您正在运行

mvn spring-boot:run

在命令行中,确保您位于包含 pom.xml 文件的目录中。否则,您将遇到 在当前项目和插件组中找不到前缀 'spring-boot' 的插件 错误。


67
投票

如果你不想使用

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>(...)</version>
</parent>

作为父 POM,您可以使用

mvn org.springframework.boot:spring-boot-maven-plugin:run

相反。


50
投票

如果您使用 Spring Boot 进行应用,忘记添加

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

可能会导致此问题,以及缺少这些行

<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>

30
投票

拼写错误可能是导致此错误的原因。

请务必检查您写的是

spring-boot
而不是例如
springboot
sprint-boot
springbok
或其他。

另请检查顺序:使用

spring-boot:run
而不是
run:spring-boot


14
投票

您可能需要将以下内容添加到您的 pom 中并尝试编译

   <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

10
投票

使用

mvn spring-boot:run
。 没有
mvn sprint-boot:run
写入错误。


9
投票

您应该从

$ mvn spring-boot:run
文件所在的文件夹运行
pom.xml
并参考此答案 https://stackoverflow.com/a/33602837/4918021


6
投票

在构建中添加 spring-boot-maven-plugin 解决了我的情况

<build>
    <finalName>mysample-web</finalName>
    <plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>springloaded</artifactId>
                <version>1.2.1.RELEASE</version>
            </dependency>
        </dependencies>
    </plugin>
    </plugins>
</build>  

3
投票

使用 mvn spring-boot:run 命令时,请确保目录中存在 pom.xml。 无需在 pom.xml 文件中添加任何内容。


2
投票

您可以添加,而不是像Bartosz的答案

中所述使用完整的插件名称(带有groupId)
<pluginGroups>
    <pluginGroup>org.springframework.boot</pluginGroup>
</pluginGroups>

到您的.m2/settings.xml。


1
投票

就我而言,在 pom.xml 中更新 Spring Boot 并在 Eclipse 中运行它后,我收到了此错误。

错误的根源是运行配置设置为离线,因此无法在运行时下载插件。


0
投票

就我而言,我的maven变量环境是M2_HOME, 所以我已经更改为 MAVEN_HOME 并工作了。

© www.soinside.com 2019 - 2024. All rights reserved.