Spring Boot开发 之 开发环境

本文的示例代码参考HelloSpring.java & HelloSpring

目录

  • SDKMAN

  • Spring Boot CLI

  • Spring Boot Initializr

  • Visual Studio Code

    • 插件

    • 调试

SDKMAN

curl -s "https://get.sdkman.io" | bash

source "$HOME/.sdkman/bin/sdkman-init.sh"

sdk version

更多参考 Installation - SDKMAN!

Spring Boot CLI

sdk install springboot

sdk list springboot

使用SDKMAN需要翻墙!

vim HelloSpring.java
@RestController
class HelloSpring {
    @RequestMapping("/")
    public String hello() {
        return "Hello Spring!";
    }
}
spring run HelloSpring.java
curl localhost:8080 # 返回"Hello Spring!"

更多参考 spring help

Spring Boot Initializr

# spring init -dweb --build gradle --groupId com.example HelloSpring
spring init -dweb --build gradle HelloSpring
# cd HelloSpring
./gradlew bootrun

更多参考 ./gradlew tasks

curl localhost:8080 # {"status":404,"error":"Not Found"}

更多参考 Spring Initializr

Visual Studio Code

插件

  • Java Extension Pack

  • Spring Boot Extension Pack

调试

  • F5

  • .vscode/launch.json

更多参考 Build Java Web Apps with VS Code

参考

  • Spring Boot实战

你可能感兴趣的:(Spring Boot开发 之 开发环境)