All Spring Boot and Spring Boot Testing Annotations

On this page, we will share all Spring boot and Spring boot testing annotations with their definitions.

All Spring Boot Annotations

  • @SpringBootConfiguration - @SpringBootApplication annotation indicates a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. This is a convenience annotation that is equivalent to declaring @Configuration, @EnableAutoConfiguration, and @ComponentScan.

Spring Boot Testing Annotations

  • @SpringBootTest - Annotated test class will load the entire application context for integration tests.
  • @WebMvcTest - Annotated test class will load only the web layer (service and data layer are ignored).
  • @DataJpaTest - Annotated class will load only the JPA components.
  • @MockBean - Marks annotated field as a mock and loads it as a bean into the application context.

Comments