【问题标题】:Maven- No plugin found for prefix 'spring-boot' in the current project and in the plugin groupsMaven-在当前项目和插件组中找不到前缀“spring-boot”的插件
【发布时间】:2015-08-31 13:55:14
【问题描述】:

我正在尝试构建一个使用 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插件,错误没有变化。

【问题讨论】:

  • 我在 Mac 中遇到了同样的问题。我可以通过将默认 java 从 13 更改为 8 来修复它。

标签: java spring maven spring-mvc


【解决方案1】:

如果你正在运行

mvn spring-boot:run

在命令行中,确保您位于包含 pom.xml 文件的目录中。否则,您将遇到No plugin found for prefix 'spring-boot' in the current project and in the plugin groups 错误。

【讨论】:

  • 不是我的解决方案。
  • 这个答案对我有帮助!
  • 正确答案。我在使用 Kotlin 创建 Spring Boot 应用程序时使用 Google Cloud Shell 时遇到了这个问题。这个答案可以帮助我解决上述问题。
  • 感谢@Voicu 这甚至对 quarkus 也有帮助
【解决方案2】:

如果你使用的是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>

【讨论】:

  • 如果这是一个子模块并且它实际上有一个父模块怎么办?
  • @DylanCzenski Per another answer below, try: mvn org.springframework.boot:spring-boot-maven-plugin:run
  • @DylanCzenski 我有同样的情况,无法添加答案中提到的父母。
【解决方案3】:

如果你不想使用

<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

改为。

【讨论】:

  • 就是我要找的!谢谢!
【解决方案4】:

错别字可能是导致此错误的原因。

请务必检查您是否写过 spring-boot 而不是例如springbootsprint-bootspringbok 或其他。

还要检查顺序:使用spring-boot:run 而不是run:spring-boot

【讨论】:

    【解决方案5】:

    您可能希望将以下内容添加到您的 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>
    

    【讨论】:

    • 为什么会发生这种情况?我在一个不允许访问外部存储库的公司网络上,我们的内部镜像似乎有正确的 JAR,但是什么会使它们变坏?
    【解决方案6】:

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

    【讨论】:

      【解决方案7】:

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

      【讨论】:

      • 还有其他答案提供了 OP 的问题,它们是前段时间发布的。发布答案 see: How do I write a good answer? 时,请确保添加新的解决方案或更好的解释,尤其是在回答较老的问题时。
      • 奇怪的是,这个答案对我有帮助:p
      • 哈哈,我赞成这个答案,因为我也有错字。
      • 我很高兴能帮上忙 :)
      • 我犯了完全相同的错误 :) 猜得不错……在我复制和粘贴之前,我什至无法读取这两个命令之间的区别:D
      【解决方案8】:

      在构建中添加 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>  
      

      【讨论】:

      • 这是我的情况。它以前可以工作,然后我评论了那部分(考虑评论其他内容),突然我的应用程序停止工作。
      【解决方案9】:

      使用 mvn spring-boot:run 命令时,确保目录中存在 pom.xml。 不需要在 pom.xml 文件中添加任何东西。

      【讨论】:

      • 我的意思是.. 错误的字面意思是执行此命令时缺少某些内容,因此必须将某些内容添加到 POM。
      • 对我来说,我什么都没加,只需要在执行命令之前在终端上的项目文件夹中。
      【解决方案10】:

      您可以添加

      <pluginGroups>
          <pluginGroup>org.springframework.boot</pluginGroup>
      </pluginGroups>
      

      到您的 .m2/settings.xml。

      【讨论】:

        【解决方案11】:

        在我的情况下,我在 pom.xml 中更新了我的 spring boot 并在 Eclipse 中运行它后出现了这个错误。

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

        【讨论】:

          【解决方案12】:

          在我的例子中,我的 maven 变量环境是 M2_HOME, 所以我改成了 MAVEN_HOME 并开始工作了。

          【讨论】:

          • 欢迎来到 Stack Overflow,@vfranca9。也许一些解释会让你的答案更清楚。 “在我的情况下”是指您在响应相同的命令时收到相同的错误消息?
          猜你喜欢
          • 2014-08-10
          • 2017-06-02
          • 1970-01-01
          • 2018-04-28
          • 2016-07-09
          • 1970-01-01
          • 2023-03-04
          • 2014-01-31
          • 2019-08-09
          相关资源
          最近更新 更多