Spring Boot

Spring Boot Annotations Explained: What Interviewers Expect You to Know

6 min read R Square IT Support TeamSample article

From @SpringBootApplication to @Transactional — the annotations you use every day, and how to explain them clearly in an interview.

Most Spring Boot interviews start with annotations because they reveal whether you understand what the framework does for you. Memorising names is not enough — be ready to explain what each one triggers.

@SpringBootApplication

A convenience annotation that combines @Configuration, @EnableAutoConfiguration and @ComponentScan. It marks the main class, enables auto-configuration based on the dependencies on your classpath, and scans the package (and sub-packages) for components.

Stereotype annotations

  • @Component — a generic Spring-managed bean
  • @Service — business logic layer (semantically clearer, same behaviour as @Component)
  • @Repository — data access layer; also translates persistence exceptions into Spring’s DataAccessException
  • @Controller / @RestController — web layer; @RestController adds @ResponseBody to every method

Dependency injection

java
@Service
public class OrderService {
    private final PaymentClient paymentClient;

    // Constructor injection — preferred: immutable and easy to test
    public OrderService(PaymentClient paymentClient) {
        this.paymentClient = paymentClient;
    }
}

Web annotations

  • @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping
  • @PathVariable for values in the URL path, @RequestParam for query parameters
  • @RequestBody to map the JSON body to an object
  • @Valid to trigger bean validation on request DTOs

@Transactional

Wraps a method in a transaction through a proxy. A common follow-up: calling a @Transactional method from another method in the same class does not start a new transaction, because the call does not go through the proxy.

Configuration

@Configuration with @Bean defines beans manually. @Value injects single properties, while @ConfigurationProperties binds a group of related properties to a typed class. @Profile activates beans only for specific environments.

  • Spring Boot
  • Annotations
  • Interview

This is a sample article published as a starter resource. Verify technical details against official documentation for the versions you use.

Prepare. Perform. Progress.

Want personal guidance on this topic?

Our team can help you prepare, solve doubts and practise interviews around what you are learning.

Chat with us