A Quick Intro to the SpringBootServletInitializer 1. Overview In this tutorial, we’ll go through a quick introduction of the SpringBootServletInitializer. This is an extension of WebApplicationInitializer which runs a SpringApplication from a traditional WAR archive deployed on a web container. This class binds Servlet, Filter and ServletContextInitializer beans from the… Continue Reading spring-boot-servlet-initializer

Obtaining Auto-generated Keys in Spring JDBC 1. Introduction In this quick tutorial, we’ll explore the possibility of getting the auto-generated key after inserting entities when working with Spring JDBC. 2. Maven Dependencies At first, we need to have spring-boot-starter-jdbc and H2 dependencies defined in our pom.xml: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId>… Continue Reading spring-jdbc-autogenerated-keys

Lombok @Builder with Inheritance 1. Overview The Lombok library provides a great way to implement the Builder Pattern without writing any boilerplate code: the @Builder annotation. In this short tutorial, we’re specifically going to learn how to deal with the @Builder annotation when inheritance is involved. We will demonstrate two techniques.… Continue Reading lombok-builder-inheritance

Mockito.mock() vs @Mock vs @MockBean 1. Overview In this quick tutorial, we’ll look at three different ways of creating mock objects and how they differ from each other – with Mockito and with the Spring mocking support. Further reading: Mockito ArgumentMatchers Learn how to use the ArgumentMatcher and how it differs from the ArgumentCaptor.… Continue Reading java-spring-mockito-mock-mockbean