Spring Boot HikariCP DataSource Configuration
HikariCP is a lightweight JDBC connection pool. Learn about various options for configuring the HikariCP with Spring boot JPA and hibernate.
HikariCP is a lightweight JDBC connection pool. Learn about various options for configuring the HikariCP with Spring boot JPA and hibernate.
Learn to use @RestClientTest annotation provided by Spring boot test module that focuses only on beans that use RestTemplateBuilder or RestTemplate.
Spring boot @DataJpaTest annotation focuses on JPA components and apply configuration only relevant to JPA tests. It helps in testing @Repository classes.
Learn how to create and customize DataSource bean in Spring boot applications and configure connection pooling and multiple datasource beans.
Learn to implement AOP in Spring Boot applications and add different aop advices using AspectJ to support cross-cutting concerns, such as logging, profiling, caching, and transaction management.
Learn how to send email in spring boot applications with the help of JavaMailSender for sending simple emails as well as emails with attachments.
Spring boot @MockBean annotation used to add mocks to a Spring ApplicationContext. In this tutorial, we will learn the different ways to use this annotation.
Learn to unit test Spring Boot webflux controller using @WebFluxTest and WebTestClient, which is used to test reactive endpoints with JUnit.
Learn to write integration tests for given Spring rest controller apis using @SpringBootTest and Junit 5. This technique can be applied to spring boot as well as spring mvc applications, both.
Learn to unit test given Spring rest controller APIs using Junit 5 and mockito. This technique can be applied to spring boot as well as spring MVC applications, both.
Learn to create and import test configurations in spring boot applications with the help of @TestConfiguration annotation.
Learn to configure Google Gson with Spring Boot 2 and 3 applications as the preferred JSON mapper. By default, Spring Boot uses Jackson.
Learn to read a file from the ‘/resources’ folder in a Spring boot application using ClassPathResource, ResourceLoader interfaces and @Value.
To disable the spring boot banner logo from the console or log files, we can make changes in 3 possible ways i.e. programmatically, properties, or startup arguments. 1. Disable Banner Programmatically Set banner mode in the program using setBannerMode(Banner.Mode.OFF) method call which starts the application. 2. Disable Banner using Properties …
Learn about some frequently used spring boot annotations as well as which work behind the scene. e.g. @SpringBootApplication and @EnableAutoConfiguration.
Learn to build Spring boot web applications supporting CRUD operations through form-based UI built on thymeleaf and spring mvc support.
Learn to configure hibernate/JPA support in Spring Boot2 applications, along with creating entity classes and extending inbuilt JpaRepository interfaces.
Learn to modify the default embedded tomcat configurations via override respective properties in application.properties file in spring boot application.
Learn to pass and retrieve the command line arguments in a Spring boot application using ApplicationArgument injection and @Value annotation.
In this Spring security oauth2 tutorial, learn to build an authorization server to authenticate your identity to provide access_token, which you can use to request data from resource server.
Learn to test spring boot async rest controller using MockMVC and @WebMvcTest which support async requests and return CompletableFuture as response type.
Learn to write unit tests for the service layer of Spring boot applications using JUnit 5 and Mockito testing frameworks. We are using Spring Boot 3 in this demo. For Spring Boot applications, we only need to change the import statements, and everything should work automatically. 1. Maven The spring-boot-starter-test …
This Spring boot MockMvc example discusses @WebMvcTest to perform integration testing of REST controller, its GET and POST methods and verify responses.
Learn to create a spring boot project having multiple modules. The parent project will work as a container for base maven configurations. The child modules will be actual spring boot projects – inheriting the maven properties from the parent project. 1. Parent Spring Boot Project The parent project is single …
Learn to add basic authentication to http requests invoked by Spring RestTemplate while accessing rest apis over the network. 1. Maven dependencies 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. …
Learn to use basic authentication to secure the REST APIs created in a Spring boot application. The secured API will ask for user authentication credentials before giving access to the API response. 1. Maven Dependency The simplest way to add all required jars is to add the latest version of …
In this Spring boot2 RestTemplate timeout example, learn to configure connection timeout and read timeout in Spring RestTemplate with example. 1. Default Timeout By default, RestTemplate uses SimpleClientHttpRequestFactory which depends on the default configuration of HttpURLConnection. Look inside the class source, and you will find this. By default, RestTemplate uses …
Learn to use Spring Boot RestTemplate for sending POST requests with JSON body, and HTTP headers including basic auth details.
In this, Spring Boot RestTemplate GET request example, learn to use RestTemplate to invoke HTTP GET API and verify the response status code and the response entity body. To create the rest APIs, use the sourcecode provided in spring boot rest api example. 1. Setup Start with including the latest …
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 …
Learn to use Spring retry module for implementing retry-based remote API invocations that can handle runtime exceptions or network failures.
Spring rmi example. Spring boot remoting example using Spring RMI and Hessian. We learned about spring remoting vs rest. Spring RMI annotation example.
Learn to use Spring RestTemplateBuilder to create or build RestTemplate bean which can be used to send HTTP requests. 1. Default RestTemplateBuilder To inject RestTemplateBuilder, pass it as a constructor argument in the service class. 2. Custom RestTemplateBuilder To create custom RestTemplateBuilder, create @Bean of type RestTemplateBuilder in Spring context. …
In this Spring boot rest interceptor example, learn to use ClientHttpRequestInterceptor with Spring RestTemplate to log request and response headers and body in Spring AOP style. 1. Spring REST Interceptor Usages We can use this interceptor for many useful tasks. 2. REST Interceptor to Log Requests and Responses Below given …
We have already gone through the RestTemplate examples for accessing REST APIs inside spring application. In this example, we are extending the configuration to use Apache HttpClient 4. The purpose of this tutorial is to give you pre-cooked recipe for little head-start, and save you from writing all bits and pieces.
The Spring boot dev tools module provides a lot of useful developer features for improving the development experience such as caching static resources, automatic restarts, live reload, global settings and running the remote applications. 1. Enabling Dev Tools Module Enabling dev tools in the spring boot application is very easy. …
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.
The spring-boot-starter-parent is a special project that provides default configuration and default dependencies for Spring Boot-based applications.
Spring CORS helps in serving web content from multiple domains into browsers who usually have the same-origin security policy. In this example, we will learn to enable CORS support in Spring MVC application at method and global level.
Learn to create Spring REST client using Spring RestTemplate class and it’s template methods to access HTTP GET, POST, PUT and DELETE requests in easy step.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.