Mac 安装Spring Boot CLI

  1. $ brew update
$ brew update
Already up-to-date.
  1. $ brew tap spring-io/tap
$ brew tap spring-io/tap
==> Tapping spring-io/tap
Cloning into '/usr/local/Homebrew/Library/Taps/spring-io/homebrew-tap'...
remote: Enumerating objects: 276, done.
remote: Counting objects: 100% (276/276), done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 276 (delta 85), reused 275 (delta 84), pack-reused 0
Receiving objects: 100% (276/276), 41.06 KiB | 201.00 KiB/s, done.
Resolving deltas: 100% (85/85), done.
Tapped 1 formula (28 files, 77.8KB).
  1. brew search spring
 brew search spring
==> Formulae
spring-io/tap/spring-boot ✔              spring-loaded
spring-completion                        spring-roo
==> Casks
mailspring                               springtoolsuite
  1. brew install spring-boot
$ brew install spring-boot
==> Installing spring-boot from spring-io/tap
==> Downloading https://repo.spring.io/release/org/springframework/boot/spring-b
######################################################################## 100.0%
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/spring-boot/2.4.2: 7 files, 13.2MB, built in 3 seconds
  1. 查看当前安装的版本
$ spring --version
Spring CLI v2.4.2
  1. 测试(编写app.groovy)
    $ vim app.groovy
    vim创建文件(文件不存在)或者编辑文件(文件存在)app.groovy, 按 i 健进入编辑模式
@RestController
class Test {
        @GetMapping("/")
        String hello() {
                "hello world!"
        }
}

编辑完成后按esc键退出编辑模式 按:wq保存并退出

  1. 运行
    $ spring run app.groovy
$ spring run app.groovy
Resolving dependencies...................

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.2)

2021-02-16 10:19:51.018  INFO 20111 --- [       runner-0] o.s.boot.SpringApplication               : Starting application using Java 15.0.2 on yanghaoyuandeMacBook-Pro.local with PID 20111 (started by yanghaoyuan in /Users/yanghaoyuan/Documents)
2021-02-16 10:19:51.026  INFO 20111 --- [       runner-0] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (jar:file:/usr/local/Cellar/spring-boot/2.4.2/lib/spring-boot-cli-2.4.2.jar!/BOOT-INF/lib/groovy-2.5.14.jar!/) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-02-16 10:19:52.651  INFO 20111 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-02-16 10:19:52.681  INFO 20111 --- [       runner-0] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-16 10:19:52.681  INFO 20111 --- [       runner-0] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-16 10:19:52.737  INFO 20111 --- [       runner-0] org.apache.catalina.loader.WebappLoader  : Unknown class loader [org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@2d6a9952] of class [class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader]
2021-02-16 10:19:52.799  INFO 20111 --- [       runner-0] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-02-16 10:19:52.799  INFO 20111 --- [       runner-0] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1476 ms
2021-02-16 10:19:53.079  INFO 20111 --- [       runner-0] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-16 10:19:53.643  INFO 20111 --- [       runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-16 10:19:53.670  INFO 20111 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 8.463 seconds (JVM running for 34.793)

  1. 验证输出是否为 hello world!
    $ curl http://localhost:8080 或者打开浏览器地址栏输入http://localhost:8080
$ curl http://localhost:8080
hello world!
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

yanghaoyuan.sh

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

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

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

打赏作者

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

抵扣说明:

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

余额充值