本文的示例代码参考HelloSpring.java & HelloSpring
目录
SDKMAN
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version
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
插件
调试
F5
.vscode/launch.json