5. Spring Boot CLI¶
The Spring Boot CLI is a command line tool that you can use if you want to quickly develop a Spring application.
5.1. 安装Spring Boot CLI¶
5.1.1. 从安装文件中手动安装¶
- 下载安装文件包 <https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/2.2.0.RELEASE/spring-boot-cli-2.2.0.RELEASE-bin.zip>
- 下载完成后,请按照解压缩后的存档中的INSTALL.txt说明进行操作。
5.2. 开始使用CLI¶
To verify the install, run the command:
spring --version
创建文件 app.groovy:
@RestController class ThisWillActuallyRun { @RequestMapping("/") String home() { "Hello World!" } }
然后从CLI运行它,如下所示:
spring run app.groovy
5.3. 使用CLI初始化项目¶
$ spring init --dependencies=web,data-jpa my-project
Using service at https://start.spring.io
Project extracted to '/Users/developer/example/my-project'