2
How to attach debug maven console applications
Andy Xu(devdiv) редактировал(а) эту страницу 2018-03-30 10:54:51 +08:00
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 typemvn package
to build the maven project and then typemvnDebug 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 to8000
(the default debug port in maven), switch to debug view, change the debug configuration to "Debug (Attach)", and press F5 to start debug, wait some time and you will see the breakpoint is hit.
{
"type": "java",
"name": "Debug (Attach)",
"request": "attach",
"hostName": "localhost",
"port": 8000
}