插件 'org.springframework.boot:spring-boot-maven-plugin:' 未找到

Lak*_*ani 28 java spring maven spring-boot

我是 Spring Boot 的新手,我打算将 h2 数据库与 maven 项目连接起来。这是我的 pom.Xml 文件。该文件给出了错误插件 'org.springframework.boot:spring-boot-maven-plugin:' not found

 <?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>
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个错误?

Wag*_*ues 80

解决了在pom.xml中添加插件版本的问题,与spring boot的版本一致。

所以你只需要像这样配置你的pom:

<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-maven-plugin</artifactId> 
<version>${project.parent.version}</version> 
Run Code Online (Sandbox Code Playgroud)

  • 我添加了“&lt;version&gt;${project.parent.version}&lt;/version&gt;”,然后将其删除,现在它可以与 IntelliJ 一起使用。 (17认同)
  • 它可以。但不知何故不起作用。这就是这篇文章存在的原因 (12认同)
  • 我在 IDEA 2021.2 中遇到了这个问题。但我在最早的版本中没有这个问题。有趣的 (5认同)
  • 这个解决方案在idea 2022.1中对我有用 (5认同)

Sal*_*dji 15

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

  • 你不应该这样写版本。相反,您应该引用版本号。 (4认同)

ayl*_*mus 14

这个解决方案对我有用:

从 Intelli J 的首选项中,导航至“构建、执行、部署 > 构建工具 > Maven”,选中“使用插件注册表”,然后单击“确定”。

然后“文件 > 无效缓存/重新启动”以重新加载 Intelli J。错误将自动消失。

我只是在 IntelliJ IDEA 中按照以下步骤操作:

单击菜单中的“文件”,然后单击“无效缓存/重新启动”


小智 8

我通过添加版本解决了这个问题:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${project.parent.version}</version>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)


Ani*_* B. 7

pom.xml的是正确的。好像是网络问题。因此没有下载插件。

解决问题的步骤:

  • 检查网络问题。您需要有强大的互联网连接才能使用 maven 下载所有依赖项和插件。否则,您肯定会遇到构建 maven 项目的问题。

  • 对于日食/STS

    1. 右键单击项目>> Run As >> Maven clean(这将通过删除目标文件夹来清理项目)。

      例子 :

在此处输入图片说明

  1. 右键单击项目>>运行方式>> Maven 安装(这将下载所有依赖项并生成目标文件夹)。

例子 :

在此处输入图片说明

  1. 如果问题仍然存在,那么最后一个选项是强制刷新项目。右键单击项目>> Maven >>更新项目

在此处输入图片说明

  1. 将出现更新 Maven 项目窗口。

在此处输入图片说明

注意:启用选项强制更新快照/发布(查看上面的屏幕截图)。默认情况下,此选项未启用。单击确定。它将开始更新。


  • 对于没有任何 IDE :
  1. 这里下载 maven并解压。

  2. 在环境变量上设置 maven 位置,以便它可以从任何地方运行。

  3. 打开 CMD/Terminal 然后mvn clean install在项目里面做。


查看者更新: <version>标签不是 spring-boot 项目的强制性标签,因为spring 为 spring-boot 创建的pom.xml可以处理spring-boot-maven-plugin.

更新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>
Run Code Online (Sandbox Code Playgroud)

编辑 :

如果上述步骤没有解决您的问题,那么您可以通过在pluginfor spring-boot-maven-plugin(不是推荐的解决方案)中明确提供父 Spring Boot 版本来寻求变通解决方案:

<plugins>
   <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>${parent.version}</version> 
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

  • '''mvn clean install''' 对我有用!我也必须从[这里](https://maven.apache.org/download.cgi)下载Maven,并且我还关注了[这个YouTube视频](https://www.youtube.com/watch?v=- -Iv5vBIHjI) (2认同)
  • 它对我不起作用。不幸的是(我对这个解决方案不满意!)只有 /sf/answers/4677746391/ 有效。 (2认同)
  • `&lt;version&gt;${parent.version}&lt;/version&gt;` 对我有用 (2认同)

小智 7

我在2022年1月版本更改为2.6.3时遇到了这个问题。我也将项目的版本降低到2.6.2,但没有成功。<version>${project.parent.version}</version>但是,无论版本如何,添加以下行插件都可以解决问题。下面给出了片段

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${project.parent.version}</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)