IntelliJ IDEA remote debugging

1. Add Remote: 

 2. Server running project

   2.1 jar package java -jar start

ps:

     The server appears Listening for transport dt_socket at address: 5005;

    The local debug starts the project, and the console appears Connected to the target VM, address: '192.168.160.130:5005', transport: 'socket'; it means that it is possible to dubug remotely.

Browser visit http://192.168.160.130:8080/demo/

The local code enters the breakpoint:

    2.2 The war package Tomcat starts

   Use the vim catalina.sh command to edit catalina.sh:

ps:

   By default, Tomcat only allows local debugging. Changing the default localhost: 8000 to 0.0.0.0:5005 means that any ip can be debugged remotely.

[root@localhost bin]# vim catalina.sh
[root@localhost bin]# ./catalina.sh jpda start
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.5.53
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.5.53
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.53/temp
Using JRE_HOME:        /usr/local/jdk1.8.0_11
Using CLASSPATH:       /usr/local/apache-tomcat-8.5.53/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.53/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]#

View the Tomcat log file catalina.out:

21-Mar-2020 20:39:11.467 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
21-Mar-2020 20:39:11.484 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 6862 ms
2020-03-21 20:39:20.214  INFO 70337 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-03-21 20:39:20.219  INFO 70337 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 4 ms
Listening for transport dt_socket at address: 5005

It can be seen that Listening for transport dt_socket at address: 5005.

3. Remote debugging, don't abuse

      Developers often use the local debugging function. Sometimes there are scenarios where the machine in the daily environment needs to be debugged remotely. In this case, there may be multiple people using the machine at the same time. The phenomenon often occurs when a person debugs remotely. This machine has caused others to wait. Others are also dumbfounded, not knowing what happened to this machine ...

As shown in the figure, all four tabs are to visit http://192.168.160.130:8080/demo/ . The four pages keep turning and waiting. . .

How to minimize the impact on others caused by remote debugging. This has some requirements for debug operators.

 If the code is as follows:

    @GetMapping(value = "/{id}")
    public String test1(@PathVariable Integer id) {
        return "hello world======>"+id;
    }

 The settings are as follows:

Visit the browser again, this time open four pages, respectively visit: http://192.168.160.130:8080/demo/1 , http://192.168.160.130:8080/demo/2 , http://192.168.160.130 : 8080 / demo / 3 , http://192.168.160.130:8080/demo/4 . As a result, only the page http://192.168.160.130:8080/demo/2 is refreshing, that is, only id == 2 Entered a breakpoint, reducing the blocking of other threads.

 

Published 187 original articles · Like 146 · Visit 490,000+

Guess you like

Origin blog.csdn.net/qq_37495786/article/details/105024440