Spring Boot

In this tutorial, you will learn about @SpringBootTest annotation. It is this annotation that you will use to write Integration Tests for your Spring Boot application. @SpringBootTest annotation is used to create a Spring Application Context that will be used during the test. It will make Spring Framework start scanning classes of your application looking…

Read More @SpringBootTest Annotation Example

You will use @MockBean annotation to create and automatically add mocks to Spring ApplicationContext. In this tutorial, we will look at different ways you can use @MockBean annotation to create mocks. If you are testing your application with JUnit and Mockito, then there are many other useful tutorials you will find in the JUnit category of…

Read More @MockBean Annotation Example

In this tutorial you will learn how to add JUnit support to your maven-based Spring Boot application. Spring Boot Starter Test Dependency To add JUnit and Mockito support to your maven-based Spring Boot application, add the following dependency to pom.xml file. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> The above dependency will add to your project many…

Read More Adding JUnit Support to Spring Boot Application

Starting from Spring Security version 5.7.0-M2 the WebSecurityConfigurerAdapter is deprecated. In this blog post you will find a complete code example that demonstrates how to configure HttpSecurity object to make it support User Authentication and User Authorization. Before Below is a code example that uses WebSecurityConfigurerAdapter. @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class WebSecurity extends WebSecurityConfigurerAdapter{…

Read More WebSecurityConfigurerAdapter is Deprecated. (Solved!)