You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add sample for tomcat debugging
Signed-off-by: Jinbo Wang <[email protected]>
* Use paragraph to format attach samples
Signed-off-by: Jinbo Wang <[email protected]>
* Fix json indentation
Signed-off-by: Jinbo Wang <[email protected]>
* Fix typos
Signed-off-by: Jinbo Wang <[email protected]>
Copy file name to clipboardExpand all lines: Configuration.md
+95-15Lines changed: 95 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,16 +126,16 @@ Before attaching to a debuggee, your debuggee program must be started with debug
126
126
}
127
127
```
128
128
129
-
In some cases, you may want to start your program with the external builder and launcher, then you can configure these jobs in [tasks.json](https://code.visualstudio.com/docs/editor/tasks) and then attach to it. For example, launching springboot application via mvn command, and then attach a debugger.
130
-
- Attaching to mvn task
131
-
-Configure your command in tasks.json - The debug job is background task, you should use *problemMatcher* filter to tell VSCode it's ready.
132
-
```json
129
+
In some cases, you may want to start your program with the external builder and launcher, then you can configure these jobs in [tasks.json](https://code.visualstudio.com/docs/editor/tasks) and attach to it. For example, launching springboot application via mvn command, and then attach a debugger.
130
+
#### Attach to mvn task
131
+
1)Configure your command in .vscode/tasks.json - The mvn task is a background task, you should use *problemMatcher* filter to tell VS Code it's ready.
"endsPattern": "^.*transport dt_socket at address.*"
201
+
}
202
+
}]
203
+
},
204
+
{
205
+
"label": "stop-tomcat",
206
+
"type": "shell",
207
+
"command": "echo ${input:terminate}}",
208
+
"problemMatcher": []
209
+
}
210
+
],
211
+
"inputs": [
212
+
{
213
+
"id": "terminate",
214
+
"type": "command",
215
+
"command": "workbench.action.tasks.terminate",
216
+
"args": "run-tomcat"
217
+
}
218
+
]
219
+
}
220
+
```
221
+
2) Use .vscode/launch.json to configure the attach configuration. Use `preLaunchTask` to run tomcat before the attach, and `postDebugTask` to stop tomcat after the debug ends.
222
+
```json
223
+
{
224
+
"version": "0.2.0",
225
+
"configurations": [
226
+
{
227
+
"type": "java",
228
+
"name": "Debug (Attach)",
229
+
"request": "attach",
230
+
"hostName": "localhost",
231
+
"port": 5005,
232
+
"preLaunchTask": "run-tomcat",
233
+
"postDebugTask": "stop-tomcat"
234
+
}
235
+
]
236
+
}
237
+
```
238
+
3) <b>F5</b> will auto start the tomcat server and attach the debugger. The demo below will show how to debug spring mvc in tomcat.
> If you want to try to debug your Java webapps in a standalone tomcat server, please try VS Code [Tomcat for Java](https://marketplace.visualstudio.com/items?itemName=adashen.vscode-tomcat) extension.
242
+
243
+
> If you want to try to debug embedded tomcat server with gradle plugin, see the [gradle sample](https://github.com/microsoft/vscode-java-debug/issues/140#issuecomment-343656398).
244
+
245
+
#### Use javac as the builder and attach to java process
246
+
1) Configure the javac builder and java runner jobs in .vscode/tasks.json.
247
+
```json
169
248
{
170
249
"version": "2.0.0",
171
250
"tasks": [
@@ -180,7 +259,7 @@ In some cases, you may want to start your program with the external builder and
180
259
"type": "shell",
181
260
"command": "java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -cp bin app.SimpleCalc",
182
261
"isBackground": true,
183
-
"problemMatcher": [{
262
+
"problemMatcher": [{
184
263
"pattern": [{
185
264
"regexp": "\\b\\B",
186
265
"file": 1,
@@ -196,9 +275,9 @@ In some cases, you may want to start your program with the external builder and
196
275
}
197
276
]
198
277
}
199
-
```
200
-
launch.json sample:
201
-
```json
278
+
```
279
+
2) Configure `preLaunchTask` and the debug port in .vscode/launch.json.
280
+
```json
202
281
{
203
282
"version": "0.2.0",
204
283
"configurations": [
@@ -212,8 +291,9 @@ In some cases, you may want to start your program with the external builder and
- `java.debug.settings.console` - The specified console to launch Java program, defaults to `integratedTerminal`. If you want to customize the console for a specific debug session, please use `console` option in launch.json instead.
0 commit comments