1/56
Flashcards covering key Spring Boot annotations, concepts, and usage scenarios.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
@SpringBootApplication
Marks the main class of a Spring Boot application, combines @Configuration, @EnableAutoConfiguration, and @ComponentScan.
@Autowired
Automatically injects dependencies by type for fields, constructors, setters, or methods.
@Component
Marks a class as a Spring-managed component (bean), used for generic components to be autodetected by classpath scanning.
@ComponentScan
Tells Spring where to scan for components, allowing customization beyond the default package.
@Bean
Declares a bean explicitly, usually in a @Configuration class, for when a bean isn't autodetected.
@Service
Specialized @Component for the business logic layer, for classes that perform service-level logic.
@Repository
Specialized @Component for persistence logic that interacts with the database and provides exception translation.
@Configuration
Marks a class for bean definitions via @Bean methods, used for Java-based bean configuration.
@EnableAutoConfiguration
Auto-configures Spring beans based on the classpath to reduce boilerplate.
@Qualifier
Resolves ambiguity when multiple beans of the same type exist by specifying which bean to inject.
@Primary
Designates a default bean to be injected when multiple candidates exist.
@DependsOn
Ensures one bean is initialized before another when bean initialization order matters.
@Profile
Loads a bean/configuration for a specific environment, such as development or production.
@Import
Imports other configuration classes to modularize configuration into separate files.
@ImportResource
Imports XML configuration files, integrating legacy Spring XML config.
@PropertySource
Loads properties from a file into Spring Environment, used to externalize configuration values.
Retention Policy in Java Annotations
Defines annotation lifespan; SOURCE discarded during compile, CLASS retained in .class file, RUNTIME retained for reflection during runtime.
ElementType in Java Annotations
Defines valid annotation targets, such as TYPE, METHOD, FIELD, PARAMETER, CONSTRUCTOR.
@RestController
Combines @Controller and @ResponseBody, used to create RESTful web services.
@RequestMapping
Maps HTTP requests to handler methods for flexible route mappings.
@GetMapping
Shorthand for @RequestMapping( method = RequestMethod.GET ), for read-only REST endpoints.
@PostMapping
Handles HTTP POST requests for creating or submitting resources.
@PutMapping
Handles HTTP PUT requests for updating existing resources.
@DeleteMapping
Handles HTTP DELETE requests for deleting resources.
@RequestParam
Binds request parameters to method arguments, allowing access to query parameters.
@PathVariable
Extracts values from URI path, useful for REST endpoints with dynamic values.
@RequestBody
Maps request JSON to Java object, handling input for POST or PUT requests.
@ResponseBody
Indicates the return value is serialized to the response body.
SpringApplication.run()
Bootstraps and launches a Spring application, serves as the entry point for running Spring Boot apps.
application.properties
Configuration file for Spring Boot apps, used to set properties like server port and database config.
application.yml
Alternative to application.properties using YAML syntax for hierarchical and cleaner configuration.
@Value
Injects property values from configuration files into fields.
@ConfigurationProperties
Binds properties to a POJO for organized and type-safe configuration mapping.
CommandLineRunner
Executes code after the app starts, used for initial setup logic like seeding data.
Actuator
Provides production-ready features like metrics and health checks for Spring Boot apps.
Spring DevTools
Offers live reload, auto-restart, and developer-friendly settings to accelerate development feedback loop.
Spring Boot Starter
A curated set of dependencies for specific functionality, simplifying dependency management.
Embedded Server in Spring Boot
Spring Boot apps run with an embedded server like Tomcat or Jetty, eliminating the need for external deployment.
@Transactional
Declares that a method should be executed within a transaction to maintain data consistency.
@ControllerAdvice
Handles exceptions globally across the whole application for centralized error handling.
Spring Security
Framework for authentication and authorization in Spring apps, securing REST APIs, login, roles, and permissions.
Spring Boot Test
Testing support for Spring Boot applications, particularly integration tests with embedded containers.
MockMvc
Utility for testing Spring MVC controllers without starting a server, used for unit testing controller logic.
TestRestTemplate
Helper class for integration testing RESTful services, testing the full HTTP lifecycle.
Spring Boot Auto Configuration
Automatically configures beans based on classpath, properties, and environment to simplify configuration.
@ConditionalOnProperty
Conditionally loads beans based on the presence or value of a property to enable or disable features.
@Conditional
Enables bean registration based on custom conditions, allowing programmatic bean registration.
Spring Boot Profiles
Environment-specific configuration mechanism used to set different configs for dev, test, and prod.
@RestTemplate
Client for performing REST calls, useful for calling external services.
WebClient
Reactive, non-blocking alternative to RestTemplate, used for async API calls in reactive applications.
Health Indicators
Custom or built-in checks for service health, exposing the /actuator/health endpoint.
Spring Boot Metrics
Tracks application metrics like memory, GC, custom counters for performance monitoring.
Spring Boot Logging
Uses SLF4J with Logback by default, allowing customization of logging levels and outputs.
Spring Boot Caching
Enables method-level caching to improve performance by caching expensive operations.
Spring Data JPA
Abstraction over JPA for simplified database access, allowing declaration of interfaces for CRUD operations.
Spring Boot JPA Auditing
Tracks entity creation and modification timestamps, automatically populating fields like createdAt and updatedAt.
Flyway / Liquibase
Version control for database schema, allowing tracking, applying, and rolling back DB migrations safely.