# Spring Boot 2.4 CLI 快速使用示例

**URL:** <https://www.isharkfly.com/t/spring-boot-2-4-cli/1074>\
**Category:** 程序语言\
**Tags:** java, spring\
**Created:** [January 5, 2021, 4:14pm UTC](https://www.isharkfly.com/t/spring-boot-2-4-cli/1074 "2021-01-05T16:14:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [January 5, 2021, 4:14pm UTC](https://www.isharkfly.com/t/spring-boot-2-4-cli/1074/1 "2021-01-05T16:14:04Z")

</div>

你可以使用下面的命令行来创建 Web 应用程序来测试你的安装是否正常。 创建一个称为 `app.groovy` 的文件，文件的内容如下：

```auto
@RestController
class ThisWillActuallyRun {

    @RequestMapping("/")
    String home() {
        "Hello World!"
    }

}

```

![spring-cli-app-01](https://www.isharkfly.com/images/transparent.png)

然后从 Shell 中运行下面的命令：

```auto
$ spring run app.groovy

```

当第一次运行你的应用程序的时候可能需要的时间比较长，这是因为系统需要从远程下载所需要的依赖。在后续运行的时候就会更加快速了。

在任何你喜欢的浏览器的地址栏中输入下面的地址：`localhost:8080` ，然后应该能够在浏览器中看到下面的输出：

```auto
Hello World!

```

![spring-cli-app-02](https://www.isharkfly.com/images/transparent.png)

访问 URL 确定输出正确。你也可以适当修改测试文件的内容，已再次确定运行正确。
