测试Spring CLI安装是否成功示例2

1.创建app.groovy文件

文件名称:app.groovy

文件内容:

@Controller

                class app{

                  @RequestMapping("/hello")

                @ResponseBody

                String hello(){

                return "hello world!";

                }

                }

2.在命令行运行该文件

命令:spring run app.groovy

3.服务启动后通过浏览器进行访问

地址:http://localhost:8080/hello

QQ截图20181217090932.png

猜你喜欢

转载自blog.51cto.com/suyanzhu/2331296