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.
- @EnableAutoConfiguration - Enables application context auto-configuration to provide possibly needed beans based on the classpath.
- @ConfigurationProperties - Provides external binding of key-value properties.
- @ConstructorBinding - Bind properties by using constructors rather than setters.
- @ConfigurationPropertiesScan - Enables auto-detection of @ConfigurationProperties classes.
- @SpringBootApplication - Combination of @SpringBootConfiguration, @EnableAutoConfiguration, @ConfigurationPropertiesScan, and @ComponentScan
- @EntityScan - Configures base packages to scan for entity classes
- @EnableJpaRepositories - Enables auto-configuration of JPA repositories
- Conditional - Annotated bean is created only if conditions are satisfied
- Additionally available in Spring Boot:
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.
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course