Spring restful web services example using spring boot

Here we will see Spring restful web services example using spring boot.  We will perform a CRUD operation.

prerequisites –

  • JDK 1.8
  • Oracle 10g
  • Eclipse
  • maven
  • postman

We will use the spring boot library (will provide dependency in pom.xml) to make sure all necessary jar/library is easily available for our application. Spring boot will take care of all jar. Let’s start.

 

Modify the pom.xml with below code.

Note – In pom.xml we have defined javac.exe path in configuration tag. You need to change accordingly i.e where you have installed JDK.

 

We are good to go. We can start writing our controller classes, ServiceImpl and Repository. Folder structure of application-

Define main class SpringRestExampleUsingOracle.java

SpringRestExampleUsingOracle.java

 

Define entity class i.e Book.java

Book.java

 

Define repository interface extending CrudRepository.

BookRepository.java

 

Define service interface i.e BookService.java

BookService.java

 

Define service implementation class.

BookServiceImpl.java

 

Define the controller class or endpoint.

BookController.java

 

Define JpaConfig class.

 

 

Step 13 – Define application.properties file

application.properties

 

Brief about flow –

 

 

We are almost done. Since we are using oracle as a database we need to use ojdbc14.jar. we will add it explicitly.

right click on project/properties/java build path/libraries/add external jar/add  ojdbc14.jar

 

Run the SpringRestExampleUsingOracle.java as java application. Our application will deploy and book table should created.

 

 

 

 

We will perform CRUD operation.

First we will save one book record using postman.

Spring restful web services example using spring boot

 

Now we have one record in DB.

 

We are good to perform get operation.

Spring restful web services example using spring boot

 

update operation.

Spring restful web services example using spring boot

We have updated autherName as ram in BookController.java.

 

delete operation.

Spring restful web services example using spring boot

That’s all about Spring restful web services example using spring boot.

How to get all loaded beans in Spring Boot application.
Spring Boot interceptor example.
Filter example in Spring Boot.
Content negotiation example using Spring Boot.
Deploy Spring boot war in JBoss EAP server.
Jboss 7 EPA datasource configuration using oracle and spring boot.
Deploy Spring Boot application on external Tomcat.
Deploy multiple war files in JBoss to different port.
Spring boot datasource configuration using tomcat

 

No post found
Top