编程知识 cdmana.com

How to use debug mode in eclipse

Eclipse Medium debug Mode usage refers to south

Debug The pattern is eclipse In the use of the program is very common debug The way , adopt debug We can locate problems more quickly , And find the reason to modify it . But many of Xiaobai's classmates are right about debug How patterns are used is not very clear , Well, I'll take you to understand eclipse Of debug The use of patterns ;

  1.  Debug Mode start mode

stay eclipse in , We run Java There are two ways to program , They are starting main Method and start the server , So for these two methods, we start debug The pattern approach is also very simple , as follows :

Main Methodical debug Mode and normal operation main Methods differ in the way that a choice Run As, A choice Debug As , The rest is the same

Start the server debug Pattern , We use tomcat For example , Normal start tomcat and debug The difference in the way you start it is that the options are different , Use debug Mode activation only needs to be in server Right click to select debug that will do :

2. The breakpoint breakpoint Use

We can do it in Java Double click the line number of the code to make a breakpoint , So when our program uses debug When the mode runs to the breakpoint , The program will pause here , Waiting for the next instruction to run , Pictured :

3.Debug View

If we run for the first time debug In mode , When the program runs to the breakpoint, a prompt appears , Pictured :

This prompt indicates that we have no default choice debug The view that the mode displays first , Click on yes You'll get into debug View , Click on no It will stay in the current view mode (Java or JavaWeb), Checked Remember my decision Words , Next time it won't show up again , And default to the selected view . Generally speaking, we don't recommend using debug View , because debug Too many windows in the view can be messy , Here's the picture :

4.Debug Run control button

We see the breakpoint for debug The importance of patterns , So when the program stops at a breakpoint , We use buttons to control the program : Run the next step or run to the end, etc , We've seen above that under normal circumstances debug Where's the control button for , So what does each button do ? I'll explain in detail here :

F8 Run to the next breakpoint of the current method , Or the next breakpoint of the descendant method of the current method call, or if there is no next breakpoint, the program runs directly ;( Not commonly used )

Ctrl+F2 End the current main program or stop server

F5 Enter the current breakpoint sub method ( Not commonly used )

F6 Go to the next step of the method where the current breakpoint is located ( Commonly used )

F7 Corresponding F5 Use , When a child method is entered, the parent method is returned ( Not commonly used )

5.JavaWeb Of debug debugging

We just saw eclipse Of debug Debugging method , So let's take a look at Javaweb Application in the project , Usually when we are debugging , Will hit the breakpoint at web Project action or controller On the first line of code corresponding to the request , The advantage of this is that the foreground request is intercepted by a breakpoint as soon as it enters the background , If the breakpoint is not intercepted, the foreground request does not enter the background , The reason is that the foreground does not send a request or the foreground request is sent but does not enter the method body (404 or 403 Or be intercepted ), Normal will enter the breakpoint , Here's the picture :

At this time, we can use the breakpoint operation control button to control , In general use F6 Step by step in the method body , If there is an error in running to a certain line , After we rerun the request , At the break point of the line ,debug After the breakpoint , We find the method that this method calls , Break point within the called method , Then press F6 Go to the breakpoint , continue debug that will do , The program above, for example 116 Bank error , Then we operate as follows :

If you run here and throw an error , We continue to find the calling method and continue debug that will do .

What I'm going to give you here is for Java Xiaobai , Yes eclipse Of debug A brief introduction to the model , It is convenient for everyone to locate and solve problems in the process of learning ;

Based on my many years of working experience and learning experience , Recorded a new set of Java Focus on video tutorials , If you are learning now Java, At the beginning of learning Java There is no systematic learning course in the process , You can add groups 654631948 Collect the learning materials , Interview questions , Development tools, etc , There are senior people in the group java The teacher answers questions , Every day, there will also be live lectures on the basic part and architecture , You can also add my wechat renlliang2013 In depth communication , As long as I really want to learn Java People welcome .

java Basic course :https://ke.qq.com/course/149432?tuin=57912c43


Java Distributed Internet Architecture / Microservices / High performance /springboot/springcloud:

https://ke.qq.com/course/179440?tuin=57912c43

版权声明
本文为[renlianggee]所创,转载请带上原文链接,感谢

Scroll to Top