Java Spring Boot - Remote Debugging in IntelliJ - Configuration

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys called for chill work in the next video today we'll learn how to use remote debugging in the IntelliJ IDE remote debugging is the technique which allow us to connect our source code with the Java process which is running on the different machine after attaching source code to the process we will be able to debug our application like we do it locally in our IDE so we will be able to use the breakpoint stop our code debug it step by step also we'll be able to use watches to check out the variable values so remote debugging is especially useful when you want to check out what is going on on your different environment or you are not able to reproduce the bug because setting up all the data is time-consuming or we are not able to do it for some religions okay let's get started you can see on the screen that I have opened student service and it is the web service which we have created in one of the videos and in the first place we want to build the fat jar so we have to go to the maven and we have to let's say clean in the first place the project oh the target should disappear yes and we want to install it and it will build our application and create the fat jar which can be deployed on the different environment it can be testing staging or production environment to debug application remotely we have to start it with special arguments and we can find these arguments over here and we have to click Edit configurations you can see that I have already created one remote configuration but we will create another one from this grudge so first of all we want to click this Add button over here and over here we want to find remote and select it so we click it and we can see that we have a new configuration we can see that it is under named right now so we can change the name so it will be easier later to find it and it say it will be service remote debug for example and also let's remove the old one important part over here for now is this command-line arguments for remote JVM over here which we want to copy and we'll use this argument to start our application from the photo jar you can also change the JDK version from here we have different options but I'm using Java 8 so I will stick with this JDK 5 to 8 the most important argument is this one over here the address because this is the port which will be exposed by the application for the remote debugging session but now we can close it up and we want to start our application we already have the fat charts so we can go over here to the target and here is our jar we want to right-click it and we'll open it in the terminals we want to go over here and open in the terminal I have few extra sessions I will close it and yeah let's imagine that we are right now on a testing environment and we want to start our new student service to check out it will behave correctly on this environment and the first thing we have to do is to start the service in the debug mode we wanted to say Java to start our jar file now we have to provide the argument which we have copied from the remote configuration and it is very important to put them before we specify which jar we want to start so I will paste them and now we want to point which jar we want to start so we will say - jar and we'll start GS rest service now we can hit enter and we can see at the very top of it that we have this listening for transport DT socket at address five zero zero five Oh our application is exposing this port for the remote debugging session that's good so we can scroll the bottom and then our application is working on the port 8080 great now we are going back from the testing environment to the developer machine and we want to attach our source code to the student service which is working on this testing environment now we have to start remote debugging session to do it we will go back to the configuration over here and we'll go quickly through this list we want to attach our source code to the rim of the JVM so this debugger mode is correct and the transport is set to socket so it's also good we'll leave it like this over here in the host input we'll live local host because we are doing everything locally but in the case and when your application which we have started locally is working on different environment for example testing environment over here you want to specify the name of the server where the application is working we also have this port input five zero zero five we will leave it like this since we have used this command over here to start our jar and this is not the port on which our student service is working but this is the port which is exposed by the Student Service for the debugging session since this port is matching the port over here in the address of the JVM argument it is all good so we can click OK before we start our debugging session let's first check out if our service is working now I have already opened the service on the port 8080 and it's also exposing the swaggered documentation so we can check it out over here and we have one student controller over here so let's test it out we will add a new student so we go to the post and we want to say try it out let's add a John Doe so with the first name will be John and the last name will be doe and you can click execute and we can see that in the console the hibernate made some inserts so now let's go to the old students and let's check out if it's really added so we say try it out execute and we can see that the student John Doe has been added now let's say that we want to debug this post method so we go to the IntelliJ or here we want to find our student controller we go to Java students control our student controller and over here we want to find our post method and it's over here now let's put the breakpoint on the line 33 now we can simply start our remote debugging session by selecting the proper configuration it's already there so it is service remove debug and we have to click the debug option and after a few seconds we can see that we have connected to the target VM with the address local host five zero zero five let's add another student to debug our post methods so we want to go back to the swagger documentation of our student service and over here we want to add another student so let's say this time it will be Tom Smith and you want to hit execute we can see that our debugging is started we can move it we hit the breakpoint in the line 33 of the art-student method and you can see that it is looking exactly the same way like the normal debugging we can see in the variables view that the first name is set to Tom the last name is set to Smith so it's all good we can jump to the another step so it is on the repository safe right now and we can jump inside but we just go through this and click the play and if we go back to our swagger documentation and scroll up and execute get all students we can see that we have Tom Smith added into the database so yeah this is how you want to set up your remote debugging in the IntelliJ I know there was a lot of talking but I wanted to explain everything so it will be easier for you to get started with it and in some cases this remote debugging is very useful so make sure to test it out and this is all for this video so thank you for watching remember about liking and subscribing see you next time
Info
Channel: CodeForgeYT
Views: 18,311
Rating: undefined out of 5
Keywords: java, spring, boot, debug, break, point, breakpoint, session, socket, address, configuration, jvm, jdk, argument, arguments, debugging, bug, expose, configure, step, into, stop, find, remote, host, port, attach, source, code, to, process, application, hot, swap
Id: 71Deeqm3pys
Channel Id: undefined
Length: 9min 26sec (566 seconds)
Published: Sat Jun 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.