Backend

Spring Boot

An opinionated layer over Spring for Java and Kotlin with auto-configuration and one-command startup.

What it is

Spring Boot removed the tedious XML setup of classic Spring. Auto-configuration picks beans from classpath dependencies, and starters pull in consistent library sets.

An app is packaged as one executable JAR with an embedded Tomcat. Actuator gives metrics and health checks, Spring Data covers databases, Spring Security covers auth.

It is the de facto standard for enterprise Java backends. It supports Kotlin, Java 21 virtual threads and GraalVM native images.

Use it when

  • Enterprise backends, banking and complex domain systems.
  • Microservices on the JVM with a ready ecosystem.
  • The team knows Java or Kotlin.

Avoid it when

  • Small scripts and prototypes: the startup is too heavy.
  • Tight memory and cold-start limits without native images.

Key concepts

Auto-configuration
Automatic bean creation based on the classpath and properties.
Starter
A dependency that pulls in a ready set of libraries.
IoC / DI
The container creates beans and injects them into other beans.
Actuator
Monitoring endpoints: health, metrics, info.

Example

A REST controller with constructor injection.

Cheat sheet

Spring Boot cheat sheet
Command or codeWhat it does
@SpringBootApplicationApplication entry point
@RestControllerController that returns JSON
@GetMapping("/users/{id}")GET handler
@PostMapping @RequestBody UserDto dtoPOST handler with a body
@PathVariable Long idPath parameter
@ServiceBusiness logic bean
interface UserRepo extends JpaRepository<User, Long>Repository without an implementation
@ValidTurns on DTO validation
./mvnw spring-boot:runRuns the application
./mvnw testRuns the tests
server.port=8081Port in application.properties

How to learn it

  1. First learn Java: collections, the Stream API and exceptions.
  2. Generate a project on start.spring.io with Web and Data JPA.
  3. Understand dependency injection and the Spring bean container.
  4. Write a REST controller with Mapping annotations.
  5. Connect PostgreSQL through Spring Data JPA and write a repository.
  6. Add validation, error handling and configuration through application.yml.
  7. Set up security with Spring Security.
  8. Write tests (JUnit, MockMvc) and build a Docker image.

Interview questions

  1. 1. What is auto-configuration?

    Spring Boot inspects the classpath and properties and creates needed beans automatically. For example, on seeing a DB driver it configures a DataSource.

  2. 2. What are a bean and IoC?

    A bean is an object managed by the Spring container. IoC means the container creates dependencies and passes them in, instead of the class calling new.

  3. 3. What is Actuator for?

    Production monitoring: health endpoints, metrics, build info. It integrates with Prometheus and Kubernetes probes.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).