简体   繁体   English

尝试执行基本 spring 引导项目时无法执行目标 org.codehaus.mojo:exec-maven-plugin

[英]Failed to execute goal org.codehaus.mojo:exec-maven-plugin when trying to execute a basic spring boot project

I created a Spring Boot Project using https://start.spring.io/ then made a Rest Controller with GET mapping to /students http I created a Spring Boot Project using https://start.spring.io/ then made a Rest Controller with GET mapping to /students http

// This is the Controller.java file
package com.exampleqqq.demoqqq;

import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping(path = "/Students")
    public List<Student> getStudents() {

        Student obj1 = new Student(7, "Saman", "Colombo");
        Student obj2 = new Student(9, "Nimal", "Matara");

        List<Student> students = new ArrayList<>();
        students.add(obj1);
        students.add(obj2);
        return students;

    }
}

// This is the DemoqqqApplication.java file // 这是DemoqqqApplication.java文件

package com.exampleqqq.demoqqq;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoqqqApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoqqqApplication.class, args);
    }

}

// This is the student.java file // 这是学生.java 文件

package com.exampleqqq.demoqqq;

/**
 *
 * @author Neva
 */
public class Student {

    private int id;
    private String name;
    private String address;

    public Student() {
        
    }
    
    public Student(int id, String name, String address) {
        this.id = id;
        this.name = name;
        this.address = address;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

}

// This is the pom.xml file // 这是 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.7.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.exampleqqq</groupId>
    <artifactId>demoqqq</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demoqqq</name>
    <description>Demo project for Spring Bootqqqqq</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <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>
        </dependency>
    </dependencies>

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

</project>

The Error is:错误是:

cd C:\Users\Neva\Documents\NetBeansProjects\demoqqq; cd C:\Users\Neva\Documents\NetBeansProjects\demoqqq; "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_341" cmd /c ""C:\Users\Neva\Documents\NetBeansProjects\demoqqq\mvnw.cmd" -Dtest=**/*IT.java "-Dmaven.ext.class.path=C:\Program Files\NetBeans-14\netbeans\java\maven-nblib\netbeans-eventspy.jar" -Dfile.encoding=UTF-8 test-compile surefire:test" Scanning for projects... "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_341" cmd /c ""C:\Users\Neva\Documents\NetBeansProjects\demoqqq\mvnw.cmd" -Dtest=**/*IT.Z93F725A07423FE1C889F448B33 Dmaven.ext.class.path=C:\Program Files\NetBeans-14\netbeans\java\maven-nblib\netbeans-eventspy.jar" -Dfile.encoding=UTF-8 test-compile surefire:test" 扫描项目...

-----------------------< com.exampleqqq:demoqqq >----------------------- Building demoqqq 0.0.1-SNAPSHOT --------------------------------[ jar ]--------------------------------- ------------------------< com.exampleqqq:demoqqq >-------------------- --- 构建 demoqqq 0.0.1-SNAPSHOT --------------------------------[ jar ]----- ----------------------------

--- maven-resources-plugin:3.2.0:resources (default-resources) @ demoqqq --- Using 'UTF-8' encoding to copy filtered resources. --- maven-resources-plugin:3.2.0:resources (default-resources) @ demoqqq --- 使用 'UTF-8' 编码复制过滤的资源。 Using 'UTF-8' encoding to copy filtered properties files.使用“UTF-8”编码复制过滤的属性文件。 Copying 1 resource Copying 0 resource复制 1 个资源 复制 0 个资源

--- maven-compiler-plugin:3.10.1:compile (default-compile) @ demoqqq --- Nothing to compile - all classes are up to date --- maven-compiler-plugin:3.10.1:compile (default-compile) @ demoqqq --- 无需编译 - 所有类都是最新的

--- maven-resources-plugin:3.2.0:testResources (default-testResources) @ demoqqq --- Using 'UTF-8' encoding to copy filtered resources. --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ demoqqq --- 使用 'UTF-8' 编码复制过滤的资源。 Using 'UTF-8' encoding to copy filtered properties files.使用“UTF-8”编码复制过滤的属性文件。 skip non existing resourceDirectory C:\Users\Neva\Documents\NetBeansProjects\demoqqq\src\test\resources跳过不存在的资源目录 C:\Users\Neva\Documents\NetBeansProjects\demoqqq\src\test\resources

--- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ demoqqq --- Nothing to compile - all classes are up to date --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ demoqqq --- 无需编译 - 所有类都是最新的

--- maven-surefire-plugin:2.22.2:test (default-cli) @ demoqqq --- ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 0.872 s Finished at: 2022-08-05T14:09:08+05:30 ------------------------------------------------------------------------ Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-cli) on project demoqqq: No tests were executed. --- maven-surefire-plugin:2.22.2:test (default-cli) @ demoqqq --- -------------------------- ---------------------------------------------- 构建失败 -- -------------------------------------------------- -------------------- 总时间:0.872 s 完成时间:2022-08-05T14:09:08+05:30 --------- -------------------------------------------------- ------------- 未能在项目 demoqqq 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-cli):未执行任何测试。 (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] (设置 -DfailIfNoTests=false 以忽略此错误。)-> [帮助 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。 Re-run Maven using the -X switch to enable full debug logging.使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。

For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException有关错误和可能的解决方案的更多信息,请阅读以下文章: [帮助 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

your commandline contains:您的命令行包含:

-Dtest=**/*IT.java

so it looks for the test with that name and a test matching that pattern does not exists.因此它会查找具有该名称的测试并且与该模式匹配的测试不存在。 So find out why your commandline has "-Dtest=**/*IT.java "所以找出你的命令行为什么有“-Dtest=**/*IT.java”

暂无
暂无

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

相关问题 我尝试运行我的Maven项目时遇到错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli) - I have an error when i trying to run my maven project: Failed execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) Maven错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Maven error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec Smooks-无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Smooks - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec( - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec ( 无法执行目标 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.4.0:exec - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec 未能执行目标 org.codehaus.mojo:exec-maven-plugin:1.5.0:exec - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec 无法在项目上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli):命令执行失败 - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project: Command execution failed Maven 不会运行我的项目:无法执行目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Maven won't run my Project : Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM