Spring Boot Fundamentals
Master Spring Boot — auto-configuration, dependency injection, REST APIs, and building production-ready Java applications rapidly.
55 min•By Priygop Team•Last updated: Feb 2026
Spring Boot Core Concepts
- Auto-Configuration: Spring Boot automatically configures beans based on classpath dependencies — add spring-boot-starter-web and you get Tomcat, Jackson, and Spring MVC configured automatically
- Dependency Injection: @Component, @Service, @Repository annotations — Spring manages object lifecycle. Constructor injection preferred over field injection for testability
- REST Controllers: @RestController + @GetMapping/@PostMapping — handle HTTP requests. @RequestBody for JSON parsing, @PathVariable for URL parameters, ResponseEntity for status codes
- Application Properties: application.yml/properties for configuration — database URLs, server ports, logging levels. Profile-specific: application-dev.yml, application-prod.yml
- Spring Boot Starters: Pre-configured dependency bundles — spring-boot-starter-data-jpa (database), spring-boot-starter-security (auth), spring-boot-starter-test (testing)
- Actuator: Production monitoring endpoints — /actuator/health, /actuator/metrics, /actuator/info. Custom health indicators for application-specific checks
Spring Data JPA
- JPA Entities: @Entity + @Table + @Id — map Java classes to database tables. @Column for field mapping, @GeneratedValue for auto-increment IDs
- Repositories: interface UserRepository extends JpaRepository<User, Long> — CRUD operations generated automatically. No implementation code needed
- Query Methods: findByEmailAndActive(String email, boolean active) — Spring generates SQL from method name. @Query for custom JPQL/native SQL queries
- Pagination: Pageable parameter — return Page<User> with total count, pages, sorting. Frontend-friendly paginated responses out of the box
- Relationships: @OneToMany, @ManyToOne, @ManyToMany — model database relationships. FetchType.LAZY default to avoid N+1 queries. Use JOIN FETCH for eager loading
- Transactions: @Transactional on service methods — automatic commit on success, rollback on exception. Read-only transactions for queries: @Transactional(readOnly = true)