Learn to create spring boot project having multiple modules. The parent project will work as container for base maven configurations. The child modules will be actual spring boot projects – inheriting the maven properties from parent project. 1. Spring boot maven parent project The parent project is single point to trigger build process for all […]
Learn to add basic authentication to http requests invoked by Spring RestTemplate while accessing rest apis over the network. 1. Maven dependency To work with Spring RestTemplate and HttpClient API, we must include spring-boot-starter-web and httpclient dependencies in pom.xml file. In this RestTemplate basic authentication tutorial, we are using dependencies. 2. Enable BasicAuth in RestTemplate […]
Learn to use basic authentication to secure rest apis created inside a Spring boot application. The secured rest api will ask for authentication details before giving access the data it secure. 1. Maven dependency To secure rest apis, we must include spring security related jar files in project runtime. Simplest way to add all required […]
In this spring boot2 RestTemplate timeout example, learn to configure connection timeout and read timeout in Spring RestTemplate with example. 1. RestTemplate default timeout By default, RestTemplate uses SimpleClientHttpRequestFactory which depends on default configuration of HttpURLConnection. Look inside the class source and you will find this. By default, resttemplate uses timeout property from JDK installed […]
In this Spring Boot RestTemplate POST request test example, we will create a POST API and then test it by sending request body along with request headers using postForEntity() method. 1. Maven dependencies Make sure to have spring-boot-starter-test dependency in the project to enable loading of spring text context, bean initialization and dependency management. 2. […]
In this, Spring Boot RestTemplate GET request example, learn to use RestTemplate to invoke REST GET API verify api response status code and response entity body. To create the rest apis, use the sourcecode provided in spring boot 2 rest api example. 1. Maven dependencies Make sure to have spring-boot-starter-test dependency in the project to […]
Learn to write Junit tests in spring boot applications. Also learn to use RestTemplate to invoke REST APIs and verify test results in success and error scenarios in this spring boot junit tutorial. To create the rest apis, use the sourcecode provided in spring boot 2 rest api example. 1. Maven dependencies Make sure to […]
Learn to consume HTTP POST REST API with Spring TestRestTemplate. In this post request test example, we will be sending request body along with request headers. 1. Maven dependencies Make sure, you have spring-boot-starter-test dependency in your project to get access to TestRestTemplate class in runtime. If you are using the @SpringBootTest annotation, a TestRestTemplate […]
Learn to create HTTP POST REST APIs using Spring boot 2 framework which accept JSON request and return JSON response to client. In this Spring Boot 2 REST POST API tutorial, we will create a REST API which returns list of employees after adding a new employee to collection. 1. Maven dependencies At first, create […]
In this spring rest tutorial, learn to create REST APIs using Spring boot 2 framework which return JSON responses to client. In this Spring Boot 2 REST API tutorial, we will create two simple GET and POST APIs step by step and test them. 1. Maven dependencies At first, create a simple maven web project […]
In this Spring boot tutorial, learn how we can build applications using spring retry module facility where we have to retry the request few times.
Spring boot log4j2 properties configuration example. This enables log4j logging into any spring boot application and start logging into console or file.
Learn to easily manage application cache from Spring boot caching support. Spring has some nice features around caching with help of cache annotations.
Spring boot @Async rest controller example. Learn to use spring async behavior with @EnableAsync annotation. Spring async completablefuture example.
Spring boot’s default logging uses Logback which is included as transitive dependency. Spring Boot supports Log4j 2 for logging configuration if it is on the classpath.
If you have worked on latest UI development frameworks e.g. Node, angular, gulp etc. then you must have appreciated the auto-reload of UI in browser whenever there is change in some code. Its pretty useful and saves a lot of time. Well, same feature can be utilized in spring boot applications using spring-boot-devtools dependency provided […]
In Spring boot applications, default packaging is jar which is deployed in embedded servers. If you want to generate a war file for deployment in seperate application server instances such as Jboss, Weblogic or tomcat, then follow below instructions.
In this spring boot tutorial, we will learn to validate request body sent to PUT/POST REST APIs. We will also learn to add custom error messages in API responses for validation errors using ResponseEntityExceptionHandler, @ControllerAdvice and @ExceptionHandler annotations.
String boot is very easy to use and it does a lot of things under the hood, you might not be aware of. In future, a good developer will be who will know exactly what is going on behind spring boot auto configuration, how to use it in your favor and how to disable certain sections which you do not want into your project.
In this Spring HATEOAS example, we will learn to add HATEOAS links to existing REST APIs created in a spring boot project. We will use the class org.springframework.hateoas.ResourceSupport along with org.springframework.hateoas.mvc.ControllerLinkBuilder and org.springframework.hateoas.Link classes provided by spring HATEOAS module. To demo the creation of links, we will first create few REST APIs and see their […]