【问题标题】:Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE未能执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE
【发布时间】:2020-04-20 06:18:22
【问题描述】:

我不明白为什么我的新项目中出现这样的错误,mvn spring-boot:run 我在执行命令时得到这个错误

错误:无法在项目 spring5webapp 上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli):运行时发生异常。空

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>guru.springframework</groupId>
    <artifactId>spring5webapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>spring5webapp</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>

    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>


    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </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>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>



</project>

【问题讨论】:

  • 你能显示整个输出和你正在执行的命令吗(也许用-v)?
  • "mvn sprin-boot:run" 执行命令@dan1st 时出现此错误
  • 你可能需要添加依赖...
  • 我有点新,你能解释一下@dan1st
  • 您已经创建了一个 spring boot 项目,但它没有依赖项。换句话说,它不使用弹簧库。如果你例如想要创建一个 web 项目,你需要 web 依赖。

标签: java spring spring-boot maven


【解决方案1】:

我尝试使用您的 pom.xml,它对我有用。仅当您具有相同的端口(8080 或您在应用程序中使用的任何端口)已被占用时,它才会失败并出现相同的错误。

您能否检查您尝试运行的端口的可用性。(如果它被占用,请尝试在其他端口上运行或杀死相同的端口)。

您也可以在堆栈跟踪中的“null”之后粘贴完整的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-27
    • 2021-11-23
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多