Java development environment to build vsCode

1. Install extension

Java Extension Pack

Spring Boot Extension Pack

Configuring Maven

Open the Settings search maven

Locate and open the editor in settings.json

Add to:

    "workbench.iconTheme": "vscode-icons",
    "workbench.startupEditor": "newUntitledFile",
    "java.errors.incompleteClasspath.severity": "ignore",
    "java.home":"C:\\Program Files\\Java\\jdk1.8.0_131",
    "maven.executable.path": "D:\\maven\\maven3.3.9\\bin\\mvn.cmd",
    "java.configuration.maven.userSettings": "\\maven\\maven3.3.9\\conf\\settings.xml",
    "maven.terminal.useJavaHome": true,
    "maven.terminal.customEnv": [
        {
            "environmentVariable": "JAVA_HOME",
            "value": "C:\\Program Files\\Java\\jdk1.8.0_131"
        }
    ],
Add path according to their own circumstances.
After configuration, reboot vscode.
 
3. Create a Spring Boot project

Shortcut key (Ctrl + Shift + p) Enter the Spring Maven project

Select Java Enter, then Enter, then Enter, select Spring Boot version

Select package need to be introduced, the introduction of several packages to meet the following web development:

DevTools (hot update code changes, without having to restart), Web (integrated tomcat, SpringMVC), Lombok (Smart Generator setter, getter, toString and other interfaces without manual generation, code more concise), Thymeleaf (template engine).

If no error will pop up prompt box, click Open it button.

4. Run the debugger

DemoApplication.java file is automatically created after the project is created, the file directory under DemoApplication New Folder Controller, create HomeController.java file.

package com.example.demo.controller;
 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {
    @RequestMapping("/test")
    public String Index() {
        return "hello";
    }
}

Add Configuration, point to the left of the small insects icon, and then point above the drop-down arrow, select Add configuration, when the first set VS Code will be prompted to select the language environment required to run automatically select the corresponding file is created launch.json environment.

 Add to
        {
            "type": "java",
            "name": "Debug (Launch)",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopOnEntry": false,
            "mainClass": "",
            "args": ""
        },
 

Selecting a corresponding configuration environment modal projects, run. Visit: http: // localhost: 8080 / test.

 

Guess you like

Origin www.cnblogs.com/liu-26/p/11649544.html