A short guide that briefly explain how to remote debug using visual studio code in a spring boot project gradle based.

Spring configuration

Open your spring project, detect the build.gradle file and edit as follow

add to “jvmArgs” the JDWP configuration passing the address properly (it is possible also to specify the ip address like address=127.0.0.1:38080)

Optional: add in an explicit way to “args ” the spring profile that you would like to use. In this case you can avoid to use undesired profile configuration.

bootRun {
	jvmArgs=["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=38080"]
	args = ["--spring.profiles.active=local"]
}

Visual studio code configuration

Open the launch.json file and edit as follow

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "java",
      "name": "Launch Program",
      "request": "attach",
      "hostName": "localhost",  //your host
      "port": 38080,  //debug port
      "projectName": "project-name"  //your project name
    }
  ]
}
Categories: JavaServer

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.