|
For the latest stable version, please use Spring Cli 0.9.0! |
Guide to Using Boot Add
You can use all the projects that are available in the project list command to add code and configuration to an existing project.
The CLI does this by:
-
Merging the Maven build file, so that any missing project properties, dependencies, dependency management, and plug-ins are added into the target project.
-
Performing a package refactoring so that the code to be copied into the target project with the same package structure.
-
Adding any missing annotations on the Spring Boot main application in the target project.
-
Renaming the
README.adoc(or .md) file toREADME-<project-name>.adocso that you can describe additional information about what code was added. -
Merging
application.yamlandapplication.propertiesfiles.
The heuristic to perform this task is not 100% complete at this time, so expect a few bumps if you are an early adopter.
For example, assume we have added the getting started catalog:
spring catalog add gs https://github.com/rd-1-2022/spring-gs-catalog
This gives us the following projects from which to select:
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโโโโโ
โName โURL โDescription โCatalogโTags โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโโโโโโโค
โweb โhttps://github.com/rd-1-2022/rpt-rest-service โHello, World RESTful web service. โgs โ[rest, web] โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโโโโโโโค
โjpa โhttps://github.com/rd-1-2022/rpt-spring-data-jpa โLearn how to work with JPA data persistence using Spring Data โgs โ[jpa, h2] โ
โ โ โJPA. โ โ โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโโโโโโโค
โeureka โhttps://github.com/rd-1-2022/eureka โSpring Cloud Eureka Server โgs โ[cloud, โ
โ โ โ โ โeureka] โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโโโโโโโ
We can create a new web project and then add JPA functionality to that project by running the following commands:
spring boot new demo web --package-name com.xkcd
cd demo
spring boot add jpa
The project tree now contains both the web application and the JPA functionality:
$ tree
.
โโโ LICENSE
โโโ mvnw
โโโ mvnw.cmd
โโโ pom.xml
โโโ README.adoc
โโโ README-jpa.md
โโโ src
โโโ main
โย โโโ java
โย โโโ com
โย โโโ xkcd
โย โโโ Application.java
โย โโโ customer
โย โย โโโ CustomerCommandLineRunner.java
โย โย โโโ Customer.java
โย โย โโโ CustomerRepository.java
โย โโโ greeting
โย โโโ GreetingController.java
โย โโโ Greeting.java
โโโ test
โโโ java
โโโ com
โโโ xkcd
โโโ customer
โย โโโ CustomerRepositoryTests.java
โโโ greeting
โโโ GreetingControllerTests.java
Conventions
To perform an intelligent merge of the code base when you run spring boot add, the following conventions in the project must be followed:
-
You should place the main
@SpringBootApplicationat the root of the package hierarchy with all other code in subpackages. -
There should be no additional
@Beanannotations in the@SpringBootApplicationclass. Any configuration should live in a separate@Configurationclass.