|
For the latest stable version, please use Spring Cli 0.9.0! |
Guide to "boot add"
All the projects that are available in the project list command can be used 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, plug-ins are added into the target project.
-
Performing a package refactoring so that the code to be copied into the target project has the same package structure.
-
Adding any missing annotations on the Spring Boot main application in the target project are added.
-
Renaming the
README.adoc`file (or, .md file) toREADME-<project-name>.adocso that additional information about what code was added can be described to the user. -
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, let’s 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 to select from
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโโโโโ
โ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 the following steps
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
In order to perform an intelligent merge of the code base when running spring boot add the following conventions in the project must be followed.
-
The main
@SpringBootApplicationshould be placed at the root of the package hiearachy with all other code in subpackages. -
There should be no additional
@Beanannotations in the@SpringBootApplicationclass. Any configuration should live in a separate@Configurationclass