> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/vii.-spring-boot-cli/64.-using-the-cli/64.1.-running-applications-with-the-cli.md).

# 64.1 使用CLI运行应用

你可以使用`run`命令编译和运行Groovy源代码。Spring Boot CLI完全自包含，以致于你不需要安装任何外部的Groovy。

下面是一个使用Groovy编写的"hello world" web应用：

hello.grooy

```java
@RestController
class WebApplication {

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

}
```

编译和运行应用可以输入：

```
$ spring run hello.groovy
```

你可以使用`--`将命令行参数和"spring"命令参数区分开来，例如：

```
$ spring run hello.groovy -- --server.port=9000
```

你可以使用`JAVA_OPTS`环境变量设置JVM命令行参数，例如：

```
$ JAVA_OPTS=-Xmx1024m spring run hello.groovy
```

**注** 在微软Windows上设置`JAVA_OPTS`时，请确保引用整个指令，如`set "JAVA_OPTS=-Xms256m -Xmx2048m"`。这样做可以确保正确地将值传递给进程。
