入门
创建一个新项目就像输入 spring boot new my-app 一样简单。
spring boot new my-app
输出为
Cloning project from https://github.com/rd-1-2022/rest-service
Created project in directory 'my-app'
如果 CLI 似乎停在克隆步骤,您可能是遇到了 GitHub 速率限制。使用 spring github auth login 命令进行认证。 |
您现在可以 cd 进入 my-app 目录并构建和运行应用程序,该应用程序默认是一个带有一个简单端点的 Web 应用程序。
cd my-app
./mvnw spring-boot:run
然后,在另一个终端窗口中,您可以使用 curl 与该端点进行交互
curl https://:8080/greeting
curl 命令返回默认的“Hello World”问候语。
{"id":1,"content":"Hello, World!"}
新项目中的 README.adoc 文件包含有关 Web 应用程序工作原理的更多信息。