spring_reference/II. Getting started/10.2.6. Quick start Spring ...

25 lines
676 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 10.2.6. Spring CLI示例快速入门
下面是一个相当简单的web应用你可以用它测试你的安装是否成功。创建一个名叫`app.groovy`的文件:
```groovy
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
```
然后简单地从一个shell中运行它
```shell
$ spring run app.groovy
```
**注**:当你首次运行该应用时将会花费一点时间,因为需要下载依赖。后续运行将会快很多。
在你最喜欢的浏览器中打开[localhost:8080](localhost:8080),然后你应该看到以下输出:
```java
Hello World!
```