Spring Boot Annotations and Concepts

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/56

flashcard set

Earn XP

Description and Tags

Flashcards covering key Spring Boot annotations, concepts, and usage scenarios.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

57 Terms

1
New cards

@SpringBootApplication

Marks the main class of a Spring Boot application, combines @Configuration, @EnableAutoConfiguration, and @ComponentScan.

2
New cards

@Autowired

Automatically injects dependencies by type for fields, constructors, setters, or methods.

3
New cards

@Component

Marks a class as a Spring-managed component (bean), used for generic components to be autodetected by classpath scanning.

4
New cards

@ComponentScan

Tells Spring where to scan for components, allowing customization beyond the default package.

5
New cards

@Bean

Declares a bean explicitly, usually in a @Configuration class, for when a bean isn't autodetected.

6
New cards

@Service

Specialized @Component for the business logic layer, for classes that perform service-level logic.

7
New cards

@Repository

Specialized @Component for persistence logic that interacts with the database and provides exception translation.

8
New cards

@Configuration

Marks a class for bean definitions via @Bean methods, used for Java-based bean configuration.

9
New cards

@EnableAutoConfiguration

Auto-configures Spring beans based on the classpath to reduce boilerplate.

10
New cards

@Qualifier

Resolves ambiguity when multiple beans of the same type exist by specifying which bean to inject.

11
New cards

@Primary

Designates a default bean to be injected when multiple candidates exist.

12
New cards

@DependsOn

Ensures one bean is initialized before another when bean initialization order matters.

13
New cards

@Profile

Loads a bean/configuration for a specific environment, such as development or production.

14
New cards

@Import

Imports other configuration classes to modularize configuration into separate files.

15
New cards

@ImportResource

Imports XML configuration files, integrating legacy Spring XML config.

16
New cards

@PropertySource

Loads properties from a file into Spring Environment, used to externalize configuration values.

17
New cards

Retention Policy in Java Annotations

Defines annotation lifespan; SOURCE discarded during compile, CLASS retained in .class file, RUNTIME retained for reflection during runtime.

18
New cards

ElementType in Java Annotations

Defines valid annotation targets, such as TYPE, METHOD, FIELD, PARAMETER, CONSTRUCTOR.

19
New cards

@RestController

Combines @Controller and @ResponseBody, used to create RESTful web services.

20
New cards

@RequestMapping

Maps HTTP requests to handler methods for flexible route mappings.

21
New cards

@GetMapping

Shorthand for @RequestMapping( method = RequestMethod.GET ), for read-only REST endpoints.

22
New cards

@PostMapping

Handles HTTP POST requests for creating or submitting resources.

23
New cards

@PutMapping

Handles HTTP PUT requests for updating existing resources.

24
New cards

@DeleteMapping

Handles HTTP DELETE requests for deleting resources.

25
New cards

@RequestParam

Binds request parameters to method arguments, allowing access to query parameters.

26
New cards

@PathVariable

Extracts values from URI path, useful for REST endpoints with dynamic values.

27
New cards

@RequestBody

Maps request JSON to Java object, handling input for POST or PUT requests.

28
New cards

@ResponseBody

Indicates the return value is serialized to the response body.

29
New cards

SpringApplication.run()

Bootstraps and launches a Spring application, serves as the entry point for running Spring Boot apps.

30
New cards

application.properties

Configuration file for Spring Boot apps, used to set properties like server port and database config.

31
New cards

application.yml

Alternative to application.properties using YAML syntax for hierarchical and cleaner configuration.

32
New cards

@Value

Injects property values from configuration files into fields.

33
New cards

@ConfigurationProperties

Binds properties to a POJO for organized and type-safe configuration mapping.

34
New cards

CommandLineRunner

Executes code after the app starts, used for initial setup logic like seeding data.

35
New cards

Actuator

Provides production-ready features like metrics and health checks for Spring Boot apps.

36
New cards

Spring DevTools

Offers live reload, auto-restart, and developer-friendly settings to accelerate development feedback loop.

37
New cards

Spring Boot Starter

A curated set of dependencies for specific functionality, simplifying dependency management.

38
New cards

Embedded Server in Spring Boot

Spring Boot apps run with an embedded server like Tomcat or Jetty, eliminating the need for external deployment.

39
New cards

@Transactional

Declares that a method should be executed within a transaction to maintain data consistency.

40
New cards

@ControllerAdvice

Handles exceptions globally across the whole application for centralized error handling.

41
New cards

Spring Security

Framework for authentication and authorization in Spring apps, securing REST APIs, login, roles, and permissions.

42
New cards

Spring Boot Test

Testing support for Spring Boot applications, particularly integration tests with embedded containers.

43
New cards

MockMvc

Utility for testing Spring MVC controllers without starting a server, used for unit testing controller logic.

44
New cards

TestRestTemplate

Helper class for integration testing RESTful services, testing the full HTTP lifecycle.

45
New cards

Spring Boot Auto Configuration

Automatically configures beans based on classpath, properties, and environment to simplify configuration.

46
New cards

@ConditionalOnProperty

Conditionally loads beans based on the presence or value of a property to enable or disable features.

47
New cards

@Conditional

Enables bean registration based on custom conditions, allowing programmatic bean registration.

48
New cards

Spring Boot Profiles

Environment-specific configuration mechanism used to set different configs for dev, test, and prod.

49
New cards

@RestTemplate

Client for performing REST calls, useful for calling external services.

50
New cards

WebClient

Reactive, non-blocking alternative to RestTemplate, used for async API calls in reactive applications.

51
New cards

Health Indicators

Custom or built-in checks for service health, exposing the /actuator/health endpoint.

52
New cards

Spring Boot Metrics

Tracks application metrics like memory, GC, custom counters for performance monitoring.

53
New cards

Spring Boot Logging

Uses SLF4J with Logback by default, allowing customization of logging levels and outputs.

54
New cards

Spring Boot Caching

Enables method-level caching to improve performance by caching expensive operations.

55
New cards

Spring Data JPA

Abstraction over JPA for simplified database access, allowing declaration of interfaces for CRUD operations.

56
New cards

Spring Boot JPA Auditing

Tracks entity creation and modification timestamps, automatically populating fields like createdAt and updatedAt.

57
New cards

Flyway / Liquibase

Version control for database schema, allowing tracking, applying, and rolling back DB migrations safely.