Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

614
Visualizações
How to debug a Java maven spring-boot app in vs code?

I was able to debug a simple Java hello world. The first step was to "compile" with javac -g. I looked up how I would acomplish the same with maven and found http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html, but those instructions are for running the application and wait for a debugger to connect.

I also tried to use target/classes for classpath in launch.json. The debugger complains that it cannot find a file in the root directory /, but it runs. Althought the debugger is running, the application is not responding to HTTP requests.

Is there a mvn command to compile the application with javac -g and produce a .class the debugger is able to run successfully?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You will only be able to remote debug with vs code, so a simple command will be mvnDebug spring-boot:run, which will do the same thing as mvn spring-boot:run but add these options:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

Then you can attach from vs code, a sample launch.json looks like:

{
 "version": "0.2.0",
  "configurations": [

    {
      "type": "java",
      "name": "Debug (Launch)",
      "request": "launch",
      "mainClass": "",
      "args": ""
    },
    {
      "type": "java",
      "name": "Debug (Attach)",
      "request": "attach",
      "hostName": "localhost",
      "port": 8000
    }
  ] 
}

and you can select Debug(Attach) from the debug panel to run.

about 4 years ago · Santiago Trujillo Relatório

0

Assuming you've installed the collection package Java Extension Pack by Microsoft debugging Maven Spring Boot applications seems to work right-out-of-the-box.

Launch code from the project's root directory and "Start Debugging". There are multiple ways to launch the debbugger -- the most straightforward is to just hit F5 and, if it asks, select Java.

Under nominal conditions this triggers the following steps:

  1. Your application is compiled into class files
  2. It finds and launches your application's main function -- which should include SpringApplication.run()
  3. The application runs (with breakpoints enabled) and log output is sent to the TERMINAL panel.

Related links:

  • https://code.visualstudio.com/docs/java/java-spring-boot
  • How can I fix build failed, do you want to continue? in vscode
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda