Spring Boot which is build upon Spring foundation itself, takes convention over configuration to the next level by reducing the development time many-fold, enabling your projects up and running as quickly as possible.

Creating Spring Boot project by creating maven project. It includes the following steps.

Step 1) Select project type.

Create New Maven Project

Step 2) Select project name and location.

Select project name and location

Step 3) Configure the project by providing Group Id, Artifact Id and Project name.

Configure Project

Step 4) After clicking finish, Spring boot project has been created. Our new project looks like the following screen shot.

Spring Boot project structure

This Maven project has a pom.xml file which contains the following default configuration.

pom.xml

We need to configure it in order to make it a Spring Boot project. Here, we are adding parent to our Maven project. It is used to declare that our project is a child to this parent project.

After that add the following dependency to the pom.xml file. Here, we are adding web dependency by adding spring-boot-starter-web.

After that add Java version for the project.

Step 5) Now, our project should have the following directly structure. You can notice that maven has created a new dependency folder to store the jar files.

Maven dependency structure

Step 6) Update Maven project each time after including new dependencies.

Maven Update Project
Select Maven Project and Update Options

Step 7) After updating Maven. Now, Create a Java class inside the src/main/java package.

Create JAVA Class

After creating class call the static run method of SpringApplication class. In the following code, we are calling run method and passing class name as argument.

SpringBootExample.java

Step 8) Now, run this class as a Java Application.

Run Spring Boot JAVA Application

Step 9) Its displays following output:

Spring Boot Output

The line Started SpringBootExample in 6.039 seconds (JVM running for 6.812) in output window shows that our application is started.

It's good to share...Share on FacebookTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Email this to someone

2 Thoughts on “Spring Boot Maven Project”

Leave a Reply

Your email address will not be published. Required fields are marked *