Configure VS Code to launch or attach to a CAP Java Spring Boot app, set breakpoints in event handlers, and inspect request context at runtime.
The Extension Pack for Java and Spring Boot Extension Pack give you a full Java debugger inside VS Code.
Install both from the VS Code Extensions panel.
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "CAP Java (Spring Boot)",
"request": "launch",
"mainClass": "com.mycompany.Application",
"projectName": "bookshop-java",
"args": "",
"vmArgs": "-Dspring.profiles.active=default"
}
]
}
Press F5 — VS Code compiles and starts the server with the debugger attached.
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
{
"type": "java",
"name": "Attach to CAP Java",
"request": "attach",
"hostName": "localhost",
"port": 5005
}
Run Attach to CAP Java from the Debug panel.
Open CatalogServiceHandler.java, click the line gutter:
@Before(event = CqnService.EVENT_READ, entity = Books_.CDS_NAME)
public void beforeReadBooks(CdsReadEventContext context) {
// ← breakpoint here
System.out.println("User: " + context.getUserInfo().getName());
}
Send a GET request to http://localhost:8080/catalog/Books — VS Code pauses at the breakpoint.
In the VS Code Variables panel when paused you can expand:
context → see userInfo, cqn (the query), parameterscontext.getUserInfo() → logged-in user detailsAfter installing the Spring Boot Extension Pack, a Spring Boot Dashboard appears in the left sidebar. It shows:
Click any endpoint to open it directly in the browser.
Sign in for progress tracking & Q&A →