Debug code skills

Configure remote debugging

To configure the idea, you only need to run debug, click Configuration and
Insert picture description here
select New (click the + sign in the upper left corner)->remote, then modify the port number to the tomcat debugging port, the JVM configuration is automatically written, after the tomcat is successfully started, then debug, you can track The code, provided that the tomcat project and your code are the same!

Code synchronization to the server

When we debug our own code remotely, we want to synchronize to tomcat to view the effect. At this time, the compiled class file is stored in tomcat, not the java file in our code. At this time, we need to Build or use Maven Clear and then complie, generate Target, find the compiled class in it and copy and paste it into tomcat. This is very troublesome. Change the synchronization once.

You can use a tool of Idea to configure the Local or mounted folder in tools->deployment-configuration, the connection is the tomcat project file, the Local path in the Mappings writes your own local file webapp, the deployment path selects your own project, and then succeeds. You can right-click the compiled class file, Deployment->upload can deploy the class file compiled by your own code to tomcat, and there will be no error, but it is a bit troublesome to restart tomcat every time, which is enough for yourself at this stage , Also remember that maven configuration compile output path
<build>
${basedir}\src\main\webapp\WEB-INF\classes
</build>
Insert picture description here
Insert picture description here

Too many breakpoints affect program performance

You can cancel the breakpoint first, run the project to the step you want to debug, then open the debugging, and continue your steps, so that the performance will not be affected by debugging in advance, and the breakpoint technique can be interrupted by the main request method. , After entering the method, next to the interruption point, do not interrupt the point in advance

Estimate the code, press alt+F8 under debug start

The evalute box appears, you can enter, estimate the result

Guess you like

Origin blog.csdn.net/weixin_43722571/article/details/103488104