Spring Boot auto-configuration, dependency injection, beans, annotations, REST controllers, Spring Data JPA, profiles and Actuator.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What does Spring Boot auto-configuration do?
Show answer
Automatically configures the Spring application based on jar dependencies found on the classpath.
- Which annotation enables Spring Boot auto-configuration?
Show answer
@EnableAutoConfiguration or @SpringBootApplication
- How do you exclude a specific auto-configuration class in Spring Boot?
Show answer
Use the exclude or excludeName attribute in @SpringBootApplication or @EnableAutoConfiguration.
- What does the spring-boot-autoconfigure JAR contain?
Show answer
Pre-written auto-configuration classes for common frameworks and libraries.
- Can you use both @SpringBootApplication and @EnableAutoConfiguration on the same class?
Show answer
No, @SpringBootApplication already includes @EnableAutoConfiguration.
- What is dependency injection in Spring?
Show answer
The process of providing objects with their dependencies rather than having objects create their own dependencies.
- Name the three types of dependency injection in Spring.
Show answer
Constructor injection, setter injection, and field injection.
- Which dependency injection method is recommended for required dependencies?
Show answer
Constructor injection.
- What does the @Autowired annotation do?
Show answer
Marks a field, setter method, or constructor as a place where Spring should inject a dependency.
- What is a Spring Bean?
Show answer
An object that is instantiated, assembled, and managed by the Spring container.
- How do you define a Spring Bean using annotations?
Show answer
Use @Bean on a method inside a @Configuration class, or use @Component, @Service, @Repository, or @Controller on a class.
- What is the default scope of a Spring Bean?
Show answer
Singleton (one instance per Spring container).
- Name three Spring Bean scopes.
Show answer
Singleton, prototype, request, session, and application.
- What annotation marks a class as a component to be detected and registered as a bean?
Show answer
@Component
- What is the difference between @Service and @Repository?
Show answer
Both are specialized @Component stereotypes; @Service is for business logic classes and @Repository is for data access classes.