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

时间:2020-11-02 04:36:26

标签: java spring spring-boot maven

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

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

非常感谢您能帮助解决此错误。

5 个答案:

答案 0 :(得分:50)

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

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

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

答案 1 :(得分:14)

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

<version>2.4.3</version>

答案 2 :(得分:2)

如果 Anish B 建议的解决方案不起作用并且您使用的是 intellij,请尝试从项目目录中删除 .idea 和 *.iml 文件,然后使用 intellij 打开 pom.xml 文件。这应该可以解决问题。

答案 3 :(得分:0)

pom.xml 是正确的。似乎存在网络问题。

由于该原因,插件未下载。

在项目上执行mvn clean install

更新了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>

答案 4 :(得分:0)

另一种可能性是,如果您在子模块中有 spring-boot-maven-plugin,父模块中有 spring-boot-starter-parent 作为父模块。

因此,带有 spring-boot-maven-plugin 的模块是 spring-boot-starter-parent 的“孙子”。

如果是这种情况,由于您无法引用祖父母的 AFAIK,您需要手动添加其 version

我愿意接受建议,因此我不需要在此类配置中手动设置 version

相关问题