Skip to main content
spring-boot logo

Building a simple REST Service with Spring Boot

Today, we are going to implement a simple REST web service using spring boot.

What you will need

  • JDK 1.8
  • Maven 3
  • Spring Boot 1.5.1
  • IntelliJ (You can use your favorite IDE)

Step by Step

1. Create a new Maven project. (You can use Gradle also).

2. Give suitable groupId and artifactId.

artifact id

3. Now your project looks like this.

project explorer

4. Add dependency and plugin into the pom.xml.

5. Add Application.Java into the com.mydevgeek.app package.

6. Then add HelloController.java into the com.devgeek.controller package

7. There are 2 ways to application run.

  • Using Command Line
  • Using IntelliJ

Run on Command Line

run following command on the terminal.

 

Run on IntelliJ

Right-click on the Application.java select “Run Application“.

 

How to test it

We can test the REST api using POSTMAN. We have to provide REST url.


Related Post

2135total visits,7visits today

RSS
Follow by Email
Facebook
Facebook
Google+
http://mydevgeek.com/building-a-simple-rest-service-with-spring-boot
Twitter