In this article, we’ll discuss various ways to create a new Spring Boot project.
2. Using Spring STS
First, let’s create a Spring Boot project using STS(Spring Tool Suite).
STS is available for eclipse, Visual Studio and Atom IDE’s. We can download the latest version of STS from the Spring Tools site.
Let’s use eclipse flavor of STS in our article.
In STS, select File –> New –> Spring Starter Project:
Let’s provide our project information in the New Spring Starter Project screen:
The configurations available in this screen are :
- Service URL — The spring boot project will be downloaded from this url. We don’t need to modify this since the Spring Boot templates are available here.
- Name — name of our Spring Boot project
- Type — indicates whether our project is a Maven or Gradle project
- Packaging — configure if build will create a jar or a war
- Java Version — the version of java to use for our project
- Language — indicates which jvm language to use. The possible options are Java, Groovy and Kotlin
- Group — the group id for our project
- Artifact — artifact id of our project
- Version — project version
- Description — some information about our project
- Package — the name of the root package
After configuring the properties, let’s click on Next to navigate to the New Spring Starter Project Dependencies screen:
The configurations available in this screen are:
- Spring Boot Version — we’ll select the version of Spring Boot from the list of supported versions.
Next, let’s select the required dependencies from the list of available dependencies.
Finally, click on Next to complete providing the properties for our Spring Boot project.
We don’t need to provide any information in the next screen. Let’s just click on Finish to create our new Spring Boot project.
3. Using Spring Initializr
In this section, let’s create a new Spring Boot project using Initializr. This is particularly useful when STS installation is not available.
First, let’s navigate to the Spring Initializr site:
Similar to project creation on STS, this page has several configurable options:
- Project — We can select either Maven or Gradle project
- Language — In this option, we can select the programming language we’ll use in the project
- Spring Boot — This section displays the list of supported Spring Boot versions. Let’s select our preferred Spring Boot version.
- Group — we’ll provide Maven group id
- Artifact — let’s provide artifact id in this field
Let’s click on More Options to provide more information on the project we are going to create:
- Name — name of our Spring Boot project
- Description — information about our project
- Package Name — name of the root package of our project
- Packaging — building Spring Boot projects can create either a jar or a war as a deployment artifact.
- Java Version — select the java version for out Spring Boot project
Next, let’s select the dependencies needed for our project. After selecting the dependencies, let’s click on Generate Project:
This starts a zip file download. We’ll unzip the file and import the project into our IDE.
4. Starting Spring Boot Application
In the previous sections, we created a new Spring Boot project. In this section, let’s see how to run our new Spring Boot application in STS.
Right click on our project and select Run As –> Spring Boot App :
And, we’ll see messages similar to the below in the console indicating that our Spring Boot app is started:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.3.RELEASE) 2019-03-11 04:27:56.700 INFO 38676 --- [ main] c.p.s.SpringBootDemosApplication : Starting SpringBootDemosApplication on ProgramSquare with PID 38676 (D:\programsquare\tutorials\SpringBootDemos\target\classes started by kiran in D:\programsquare\tutorials\SpringBootDemos)
In this article, we discussed various options to create a Spring Boot project. Then, we started the project from STS. We can use any one of the options to create a new Spring Boot project.