然后执行$ spring run app.groovy,第一次执行会下载依赖,会慢一些,之后就很快了,通过localhost:8080可以访问这个应用。
如果想指定别的端口:
1
$ spring run hello.groovy -- --server.port=9000
这里的--用于区分传递给spring应用的参数和传递给cli的参数。
新建项目
Spring Boot CLI可以新建项目,他其实是调用start.spring.io来新建项目。比如:
1 2 3
$ spring init --dependencies=web,data-jpa my-project Using service at https://start.spring.io Project extracted to '/Users/developer/example/my-project'
$ spring init --list ======================================= Capabilities of https://start.spring.io =======================================
Available dependencies: ----------------------- actuator - Actuator: Production ready features to help you monitor and manage your application ... web - Web: Support for full-stack web development, including Tomcat and spring-webmvc websocket - Websocket: Support for WebSocket development ws - WS: Support for Spring Web Services
$ spring init --build=gradle --java-version=1.8 --dependencies=websocket --packaging=war sample-app.zip Using service at https://start.spring.io Content saved to 'sample-app.zip'