Spring Boot CLI安装及启动第一个项目

Spring Boot CLI是一个命令行工具,用于使用Spring快速开发。 它允许运行Groovy脚本,Groovy脚本类似于没有任何样板代码的java代码。 Spring CLI有助于引导新项目或编写自定义命令。

1、下载Spring Boot CLI

下载地址:JFrog (spring.io)

2、安装jdk

下载完成后解压文件,在INSTALL.txt文件中有使用说明:

Spring Boot CLI requires Java JDK v1.8 or above in order to run. Groovy v${groovy.version}
is packaged as part of this distribution, and therefore does not need to be installed (any
existing Groovy installation is ignored).

The CLI will use whatever JDK it finds on your path, to check that you have an appropriate
version you should run:

	java -version

Alternatively, you can set the JAVA_HOME environment variable to point a suitable JDK.

大概意思是 使用Java JDK v1.8或者以上运行,配置环境变量并执行 java -version 去测试,是否安装成功。 那就去下载安装jdk。

3、配置环境变量

To test if you have successfully installed the CLI you can run the following command:

	spring --version

使用 spring --version 命令去测试是否成功(springboot的环境变量可配,也可不配置)

 注意是两个横杠- - version

4、新建groovy文件或java文件

// 新建文件app.groovy,启动:spring run app.groovy
@RestController
class ThisWillActuallyRun {
    @RequestMapping("/")
    String home() {
       "Hello World!"
    }
}

// 或者 新建文件app.java,启动:spring run app.java
@RestController
class ThisWillActuallyRun {
    @RequestMapping("/")
    String home() {
       "Hello World!"
    }
}

Resolving dependencies过程会下载相关资源,默认位置 C:\Users\ 用户名 \.m2\repository

tomcat端口号8080

这就完成了一个Spring程序。很方便,不用下载IDE。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

种麦南山下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值