-
Notifications
You must be signed in to change notification settings - Fork 375
How to attach debug maven console applications
I will take maven quickstart project as example:
step 1. create the simple-app project, open a terminal and type:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart
then input the groupId and artifactId:
step 2: open the generated folder simple-app
in vscode, wait for the startup of java extensions:
step 3: set a breakpoint at App.java and F5, choose java
, a new folder named .vscode
should be created
step 4: in terminal, goto the simple-app
folder and type mvn package
to build the maven project and then type mvnDebug exec:java -Dexec.mainClass="com.ms.samples.App"
to start the mvn debug:
(be careful about the package name, it should be the groupId you have inputted in step 1)
step 5: back to vscode, modify the launch.json inside the .vscode
folder and change the port to 8000
(the default debug port in maven), switch to debug view, change the
{
"type": "java",
"name": "Debug (Attach)",
"request": "attach",
"hostName": "localhost",
"port": 8000
}