How to debug Spring Boot application with Eclipse?

后端 未结 13 2441
星月不相逢
星月不相逢 2020-12-04 07:04

My Spring Boot webapp is running just fine, and I\'d like to debug it through Eclipse.

So when launching my Remote Java Application debugger, which port

相关标签:
13条回答
  • 2020-12-04 07:20

    Right click on the Spring Boot Applications main class file -> select Debug As options -> Select Java Application

    Now you can use breakpoints to debug the application.

    0 讨论(0)
  • 2020-12-04 07:22

    There's section 19.2 in Spring Boot Reference that tells you about starting your application with remote debugging support enabled.

    $ java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n \
       -jar target/myproject-0.0.1-SNAPSHOT.jar
    

    After you start your application just add that Remote Java Application configuration in Run/Debug configurations, select the port/address you defined when starting your app, and then you are free to debug.

    0 讨论(0)
  • 2020-12-04 07:22

    Please see http://java.dzone.com/articles/how-debug-remote-java-applicat to enable the remote debugging. If you are using tomcat to run your application, start tomcat with remote debug parameters or you can start tomcat with JPDA support by using following command.

    Windows

    <tomcat bin dir>/startup.bat jpda
    

    *nix

    <tomcat bin dir>/startup.sh jpda
    

    this will enable remote debugging on port 8000

    0 讨论(0)
  • 2020-12-04 07:26

    The best solution in my opinion is add a plugin in the pom.xml, and you don't need to do anything else all the time:

    <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <jvmArguments>
                            -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9898
                        </jvmArguments>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    
    0 讨论(0)
  • 2020-12-04 07:26
    • right click on your project and choose "Debug As => Java application or Spring boot App" -capture1 -
    • If you want that your application pause in somewhere in your app double click on the left you will have like this capture 2.
    • then when you start your app use those arrows to go next.(capture 3)
    0 讨论(0)
  • 2020-12-04 07:26

    With eclipse or any other IDE, just right click on your main spring boot application and click "debug as java application"

    0 讨论(0)
提交回复
热议问题