59.5 初始化新工程

init命令允许你使用start.spring.io在不离开shell的情况下创建一个新的项目,例如:

$ spring init --dependencies=web,data-jpa my-project
Using service at https://start.spring.io
Project extracted to '/Users/developer/example/my-project'

这创建了一个my-project目录,它是一个基于Maven且依赖spring-boot-starter-webspring-boot-starter-data-jpa的项目。你可以使用--list参数列出该服务的能力。

$ 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

Available project types:
------------------------
gradle-build -  Gradle Config [format:build, build:gradle]
gradle-project -  Gradle Project [format:project, build:gradle]
maven-build -  Maven POM [format:build, build:maven]
maven-project -  Maven Project [format:project, build:maven] (default)

...

init命令支持很多选项,查看help输出可以获得更多详情。例如,下面的命令创建一个使用Java8和打包为war的gradle项目:

$ 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'

results matching ""

    No results matching ""