'Adding dependencies to existing project via Spring CLI
Is there any way to add dependencies to existing spring project using Spring CLI (for instance via shell)?
I tried to looked for on this website docs.spring.io.
But I couldn't find working way of adding dependency like Spring Web
or Spring Data JPA
to existing spring project.
Solution 1:[1]
You can use pom.xml to add dependencies to your existing spring project whether you created your project by using Spring CLI or any other way.
- Go to Maven Repository: https://mvnrepository.com/
- Search for your required dependencies
- Copy the dependency for maven and paste it in your pom.xml
Solution 2:[2]
If you are using STS
or Eclipse
for your development then you can easily add dependencies
using CLI
.
You need to press the Ctrl+Space Bar
in your pom.xml
.
It will show you the option with Edit starters
as shown below, then click on it it will open your CLI interface
Solution 3:[3]
To add a dependancy from Spring CLI, you can use the following command:
spring init -a <name_of_your_artifact> --dependencies=web,data-jpa <my_project>
where:
<name_of_your_artifact>: the artifact Id for the project.
and
<my_project>: name of the file where the .zip of spring initilizer will be extractred.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | chillcoder101 |
Solution 2 | SSK |
Solution 3 | samivic |