简体   繁体   English

找不到插件“org.springframework.boot:spring-boot-maven-plugin:”

[英]Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found

I'm facing an error in my pom.xml file given below:我在下面给出的pom.xml文件中遇到错误:

Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found

Below is my pom.xml:下面是我的 pom.xml:

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>dev.che</groupId>
    <artifactId>stu</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>stu</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

How can I fix this error?我该如何解决这个错误?

I fixed the problem adding the version of the plugin in the pom.xml, which is the same of spring boot's version.我修复了在 pom.xml 中添加插件版本的问题,这与 spring boot 的版本相同。 (and it's working since spring boot 2.2 until 2.7.X) (它从 Spring Boot 2.2 到 2.7.X 一直有效)

So you just have to configure your pom like this:所以你只需要像这样配置你的pom:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${project.parent.version}</version>
</plugin>

我修复了在 pom.xml 中添加插件版本的问题

 <version>${project.parent.version}</version>

The pom.xml is correct. pom.xml是正确的。 It seems that there is a network issue.好像是网络问题。 The plugin was not downloaded due to that.由于这个原因,该插件没有被下载。

Steps to solve the issue :解决问题的步骤:

  • Check for network issue.检查网络问题。 You need to have a strong internet connection to download all the dependencies and plugins using maven.您需要有强大的互联网连接才能使用 maven 下载所有依赖项和插件。 Otherwise, you will face issue to build maven project for sure.否则,你肯定会面临构建 maven 项目的问题。

  • For eclipse/STS :对于日食/STS

    1. Right click on the project >> Run As >> Maven clean (this will clean the project by deleting the target folder).右键单击项目>> Run As >> Maven clean (这将通过删除目标文件夹来清理项目)。

      Example :例子 :

在此处输入图像描述

  1. Right click on the project >> Run As >> Maven install (this will download all dependencies and generate target folder).右键单击项目>>运行方式>> Maven 安装(这将下载所有依赖项并生成目标文件夹)。

Example :例子 :

在此处输入图像描述

  1. If problem still persists, then last option is to force refresh of the project.如果问题仍然存在,那么最后一个选项是强制刷新项目。 Right click on the project >> Maven >> Update Project .右键单击项目>> Maven >>更新项目

在此处输入图像描述

  1. Update Maven Project Window will be come.会出现更新 Maven 项目窗口。

在此处输入图像描述

Note: Enable the option Force update of Snapshot/Releases (look in above screenshot).注意:启用选项强制更新快照/发布(查看上面的屏幕截图)。 By default, this option is not enabled.默认情况下,此选项未启用。 Click on ok.点击确定。 It will start updating.它将开始更新。


  • For Intellij IDE :对于Intellij IDE
  1. Open the Maven tab present on the right tab and check for spring-boot-maven-plugin.打开右侧选项卡上的 Maven 选项卡并检查 spring-boot-maven-plugin。

在此处输入图像描述

  1. If the plugin was not downloaded, then click on clean maven lifecycle and it delete the folders that were generated by maven.如果插件没有下载,那么点击clean maven 生命周期,它会删除 maven 生成的文件夹。

在此处输入图像描述

  1. Then, click on install maven lifecycle and it will download all the dependencies and generate all the folders from scratch required for the project.然后,单击安装maven 生命周期,它将下载所有依赖项并从头开始生成项目所需的所有文件夹。

在此处输入图像描述

  1. Last step is to force update of the project.最后一步是强制更新项目。 You need to click on the Generate Sources and Update Folders for All Projects option.您需要单击Generate Sources and Update Folders for All Projects选项。

在此处输入图像描述

Note : Go the Preference -> Build, Execution and Deployment -> Build Tools -> Maven -> Enable "Always update Snapshots" option present -> Click on Apply and Ok .注意:转到首选项->构建、执行和部署->构建工具-> Maven ->启用“始终更新快照”选项-> 单击应用确定 This option helps sometimes.此选项有时会有所帮助。


  • For Without any IDE :对于没有任何 IDE :
  1. Download maven from here and extract it.这里下载 maven 并解压。

  2. Set maven location on the environment variable so that it can run from anywhere.在环境变量上设置 maven 位置,以便它可以从任何地方运行。

  3. Open CMD/Terminal and then do mvn clean install inside the project.打开 CMD/Terminal,然后在项目中执行mvn clean install


Update for viewers: <version> tag is not mandatory tag to be there for spring-boot projects because pom.xml created by spring for spring-boot can handle the version of the spring-boot-maven-plugin .查看者更新: <version>标签不是 spring-boot 项目的强制性标签,因为 spring 为 spring-boot 创建的pom.xml可以处理spring-boot-maven-plugin的版本。

Updated pom.xml :更新pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>dev.che</groupId>
    <artifactId>stu</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>stu</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Edit :编辑 :

If above steps are not solving your issue, then you can go for the workaround solution by explicitly providing the parent spring boot version in the plugin for spring-boot-maven-plugin (not a recommended solution):如果上述步骤没有解决您的问题,那么您可以通过在spring-boot-maven-plugin plugin显式提供父 Spring Boot 版本来寻求解决方案(不是推荐的解决方案):

<plugins>
   <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>${parent.version}</version> 
    </plugin>
</plugins>

This solution worked for me:这个解决方案对我有用:

From the Preferences in Intelli J, navigate to "Build, Execution, Deployment > Build Tools > Maven", check the "Use plugin registry", and click "OK".从 Intelli J 的首选项中,导航到“构建、执行、部署 > 构建工具 > Maven”,选中“使用插件注册表”,然后单击“确定”。

Then "File > Invalidate Caches / Restart" to reload Intelli J. The error will go away automatically.然后“文件 > 使缓存无效/重新启动”以重新加载 Intelli J。错误将自动消失。

I just followed these steps in IntelliJ IDEA:我只是在 IntelliJ IDEA 中按照以下步骤操作:

Click File from menu and then click Invalidate Caches / Restart .单击菜单中的File ,然后单击Invalidate Caches / Restart

If solution suggested by Anish B doesn't work and you are using intellij, try deleting the .idea and *.iml file from the project directory and open the pom.xml file with intellij.如果 Anish B 建议的解决方案不起作用并且您正在使用 intellij,请尝试从项目目录中删除 .idea 和 *.iml 文件,然后使用 intellij 打开 pom.xml 文件。 This should fix the issue.这应该可以解决问题。

I encountered this issue in January 2022 when the version changed to 2.6.3.我在 2022 年 1 月版本更改为 2.6.3 时遇到了这个问题。 I lowered the version of the project to 2.6.2 as well but was unsuccessful.我也将项目的版本降低到 2.6.2,但没有成功。 However adding the following line <version>${project.parent.version}</version> plugins solves the issue regardless of the version.但是,添加以下行<version>${project.parent.version}</version> plugins 可以解决问题,无论版本如何。 The snippet is given below片段如下

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${project.parent.version}</version>
</plugin>

Another possibility is if you have spring-boot-maven-plugin in a sub-module which parent has spring-boot-starter-parent as parent.另一种可能性是,如果您在子模块中有spring-boot-maven-plugin ,而父级将spring-boot-starter-parent作为父级。

So, the module with spring-boot-maven-plugin is a 'grandchild' of spring-boot-starter-parent .因此,带有spring-boot-maven-plugin的模块是spring-boot-starter-parent的“孙子”。

If that's the case, since you can't reference AFAIK the grandparent, you need to manually add its version .如果是这种情况,由于您无法引用祖父母的 AFAIK,您需要手动添加其version

I am open to recommendations, so that I don't need to manually set the version in such a configuration.我愿意接受建议,因此我不需要在这种配置中手动设置version

I had this issue today 22 Jan 2022 using spring boot 2.6.3 from Intelij IDE and was able to resolve it by changing from 2.6.3 back to 2.6.2 .As of the time of writing I was getting this error我在 2022 年 1 月 22 日今天使用 Intelij IDE 的 spring boot 2.6.3 遇到了这个问题,并且能够通过从 2.6.3 更改回 2.6.2 来解决它。截至撰写本文时,我遇到了这个错误

Cannot resolve plugin org.apache.maven.plugins:maven-jar-plugin:3.2.2无法解析插件 org.apache.maven.plugins:maven-jar-plugin:3.2.2

    <parent>
      <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.6.2</version>  <!-- change 2.6.3 to 2.6.2-->
         <relativePath/>
    </parent>

it works definetely : add this <version>${project.parent.version}</version> in Pom.xml like this :它的工作原理很明确:在Pom.xml中添加这个<version>${project.parent.version}</version> ,如下所示:

<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-maven-plugin</artifactId> 
<version>${project.parent.version}</version> 

or another solution is : add <version>2.4.3</version> in pom.xml或另一种解决方案是:在pom.xml中添加<version>2.4.3</version>

Simply add version of the spring-boot-starter-parent in the plugin section ie只需在插件部分添加 spring-boot-starter-parent 的版本,即

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>

Change into变成

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.5.RELEASE</version>
</plugin>

check out here for more details这里查看更多详细信息

This could be due to network issue which lead to partial download of dependencies and plugins.这可能是由于网络问题导致部分下载依赖项和插件。 For me below step worked in IntelliJIDEA:对我来说,以下步骤在 IntelliJIDEA 中工作:

Close the project from editor: File -> Close Project从编辑器中关闭项目:文件 -> 关闭项目

Then reopen the project.然后重新打开项目。

Add in "Remote Jar Repositories"添加“远程 Jar 存储库”

https://mvnrepository.com/artifact/

And add in pom.xml并添加pom.xml

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>

    </dependency>

then add in *.java然后添加*.java

import org.springframework.transaction.annotation.Transactional;

我将带有控制器的包移到了 IntroApplication 所在的包中,对于像我这样的菜鸟来说,它解决了这个问题。

右键单击我的 pom.xml -> Maven -> Reload Project 为我解决了问题。

Your dependencies are not loaded into your project if you declared them at a later point.如果您稍后声明它们,您的依赖项不会加载到您的项目中。

For IntelliJ IDEA对于 IntelliJ IDEA

Right click on your project > Maven > Reload Project右键单击您的项目 > Maven >重新加载项目

This should fix the error.这应该可以修复错误。

I tried a lot of the solutions here but only this worked for me:我在这里尝试了很多解决方案,但只有这个对我有用:

Changing the Maven wrapper to "Bundled" in the "Maven home path" configuration.在“Maven 主路径”配置中将 Maven 包装器更改为“捆绑”。 You can find this at the menu Preferences > Build,execution, development >build tools > maven您可以在菜单首选项 > 构建、执行、开发 > 构建工具 > maven 中找到它

enter image description here在此处输入图像描述

just use the last version of spring-boot-maven-plugin只需使用最新版本的spring-boot-maven-plugin

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-maven-plugin https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-maven-plugin

or use same version of或使用相同版本的

    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.1</version>

For intellij对于智能

  • right click on the pom.xml右键单击 pom.xml
  • locate maven and select rebuild rebuild project.找到 maven 和 select 重建重建项目。

In your pom.xml file, go to the plugins section and then add this line below artifactId.在您的 pom.xml 文件中,go 到插件部分,然后将此行添加到 artifactId 下方。

<version>${project.parent.version}</version>

Your code should look like this:您的代码应如下所示:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>

Then load maven changes and it should fix your problem.然后加载 maven 更改,它应该可以解决您的问题。

In my case it was just inserting the Spring Boot parent version and the error disappeared spring-boot-starter-parent 3.0.1 stayed like this org.springframework.boot spring-boot-maven-plugin 3.0.1在我的例子中,它只是插入 Spring Boot 父版本,错误消失了 spring-boot-starter-parent 3.0.1 保持这样 org.springframework.boot spring-boot-maven-plugin 3.0.1

I faced this error while learning Springboot in 2023, I easily fix it by adding the following line at the spring-boot-starter-web dependency:我在 2023 年学习 Springboot 时遇到了这个错误,我通过在 spring-boot-starter-web 依赖项中添加以下行轻松修复它:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>${project.parent.version}</version>
    </dependency>

Quick solution快速解决方案

I tried all the solutions above and realized that the dependencies were not being downloaded.我尝试了上述所有解决方案,并意识到没有下载依赖项。 That's when I knew it was a network issue.那时我知道这是一个网络问题。 My network was strong so I knew it had too be the firewall.我的网络很强大,所以我知道它也是防火墙。 I added intellij IDE to my list of exceptions and it worked like charm.我将 intellij IDE 添加到我的异常列表中,它的工作原理非常有魅力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 插件org.springframework.boot:spring-boot-maven-plugin? - Plugin org.springframework.boot:spring-boot-maven-plugin? Maven - 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.1:run - Maven - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:run 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run 无法执行目标org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.8:run - org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.8:run 插件 org.springframework.boot:spring-boot-maven-plugin:1.3.0.BUILD-SNAPSHOT 或其依赖项之一无法解析 - Plugin org.springframework.boot:spring-boot-maven-plugin:1.3.0.BUILD-SNAPSHOT or one of its dependencies could not be resolved 无法在插件org.springframework.boot中找到目标:&#39;spring-boot-maven-plugin:1.1.4.RELEASE可用目标重新打包 - Could not find goal '' in plugin org.springframework.boot:spring-boot-maven-plugin:1.1.4.RELEASE among available goals repackage 目标org.springframework.boot的执行默认值:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename - Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM