【问题标题】:ERROR No plugin found for prefix 'spring' in the current project错误在当前项目中找不到前缀“spring”的插件
【发布时间】:2020-01-06 12:12:22
【问题描述】:

我刚刚创建了一个 Spring Boot 项目,它在 Intellij IDE 中运行良好。但是,当我尝试从终端运行项目时,我收到消息,

$ mvn spring:boot run 
[INFO] Scanning for projects...
Downloading from spring-milestones: https://repo.spring.io/milestone/org/codehaus/mojo/maven-metadata.xml
Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/codehaus/mojo/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 6.3 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 11 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.715 s
[INFO] Finished at: 2020-01-06T18:03:47+06:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'spring' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/Chaklader/.m2/repository), spring-milestones (https://repo.spring.io/milestone), spring-snapshots (https://repo.spring.io/snapshot), 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

我使用命令$ mvn spring:boot run 从终端运行项目。

下面提供了我的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.2.3.BUILD-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</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-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>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

我发现同一个查询有几个问题,但是,我认为我的项目是正确的,因为它在 IDE 中运行良好,那么,为什么它会在 OS X 终端中中断?

【问题讨论】:

  • 我知道问题本身很简单,但是我花了很多时间没有解决问题。
  • 你使用了错误的命令,使用 mvn spring-boot:run
  • @YogendraR 非常感谢。此命令也有效:$ mvn org.springframework.boot:spring-boot-maven-plugin:run 请您将它们写在答案中以便对其他人有帮助吗?我不是一个完整的初学者,我也浪费时间。
  • 如果你不打算,我也可以写命令作为答案。

标签: spring spring-boot maven intellij-idea terminal


【解决方案1】:

使用命令:mvn spring-boot:run

【讨论】:

  • 这个命令也可以正常工作:$ mvn org.springframework.boot:spring-boot-maven-plugin:run
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-02-28
  • 2015-08-31
  • 2023-03-04
  • 2014-01-31
  • 2021-05-31
  • 2020-06-24
  • 1970-01-01
相关资源
最近更新 更多