debug maven project in eclipse

Greeter.java

package hello;

public class Greeter {
    public String sayHello() {
        return "Hello world!";
    }
}

HelloWorld.java

package hello;

public class HelloWorld {
    public static void main(String[] args) {
        Greeter greeter = new Greeter();
        System.out.println(greeter.sayHello());
    }
}  

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>

    <groupId>org.springframework</groupId>
    <artifactId>gs-maven</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
          	<plugin>
			  <groupId>org.codehaus.mojo</groupId>
			  <artifactId>exec-maven-plugin</artifactId>
			  <version>1.1</version>
			  <executions><execution>
			    <goals><goal>java</goal></goals>
			  </execution></executions>
			  <configuration>
			    <mainClass>hello.HelloWorld</mainClass>
			  </configuration>
			</plugin>
        </plugins>
    </build>
</project>

雙擊下斷點, 然後Debug as -> Maven build
在Goals裏面敲入 exec:java
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章