Spring Boot Annotations Explained

What are Spring Boot annotations? They are markers (like @RestController or @Service) that tell Spring what a class or method does, so Spring can create objects, connect them, map URLs, validate data and manage transactions for you. Learn them by layer: setup (@SpringBootApplication), web (@RestController, @GetMapping), business (@Service, @Transactional), data (@Entity, @Repository), validation (@Valid, @NotBlank) and testing (@SpringBootTest).

This guide from VibrantMinds Technologies in Pune explains the 40+ Spring Boot annotations freshers actually meet, with examples, a cheat sheet and interview answers. It is written for anyone searching Spring Boot annotations, Spring Boot annotations list with examples, Spring Boot annotations for freshers, Spring Boot annotations interview questions, @RestController vs @Controller, @Component vs @Service vs @Repository, @Autowired vs constructor injection, @RequestParam vs @PathVariable, Spring Boot annotations cheat sheet or a free IT job WhatsApp group for Java freshers in Pune.

Takeaway

Detail

Annotations are instructions to Spring

They say what a class is and how it should behave.

Learn them by layer

Web, service, repository, entity, validation, tests.

Prefer constructor injection

It is clearer and easier to test than field @Autowired.

@SpringBootApplication bundles three annotations

@Configuration, @EnableAutoConfiguration and @ComponentScan.

Know the stereotype differences

@Component, @Service, @Repository and @Controller are specialisations.

@Transactional has rules

It works through proxies, so self-calls and private methods can surprise you.

Explain with a flow

Request, controller, service, repository, database.

THE BIG PICTURE: ANNOTATIONS BY LAYER




GROUP 1: SETUP AND CONFIGURATION

Annotation

What it does

@SpringBootApplication

Marks the main class. Combines @Configuration, @EnableAutoConfiguration and @ComponentScan.

@EnableAutoConfiguration

Lets Spring Boot configure beans automatically based on your dependencies.

@ComponentScan

Tells Spring which packages to scan for components.

@Configuration

Marks a class that defines beans.

@Bean

Marks a method whose return value becomes a Spring-managed bean.

java

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

java

@Configuration
public class AppConfig {
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
@Configuration
public class AppConfig {
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
@Configuration
public class AppConfig {
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}

Common problem: classes outside the main class’s package (or its sub-packages) are not scanned, which causes NoSuchBeanDefinitionException. Keep the main class in the root package.

GROUP 2: STEREOTYPE AND DEPENDENCY INJECTION

Stereotype annotations

Annotation

Use for

Extra meaning

@Component

Any generic Spring-managed class

Base stereotype

@Service

Business logic classes

Marks the service layer

@Repository

Data access classes

Also translates persistence exceptions

@Controller

MVC controllers returning views

Web layer

@RestController

REST API controllers

@Controller + @ResponseBody

@Component vs @Service vs @Repository: all create Spring beans. The specific ones document the role of the class, and @Repository adds exception translation.

Dependency injection annotations

Annotation

What it does

@Autowired

Asks Spring to inject a dependency

@Qualifier("name")

Chooses a specific bean when several match

@Primary

Marks the default bean when several match

@Lazy

Creates the bean only when first needed

@Scope

Sets the bean scope (singleton by default, prototype and others)

@PostConstruct

Runs a method after the bean is created and dependencies are injected

Constructor injection (recommended)

java

@Service
public class StudentService {

    private final StudentRepository repository;

    public StudentService(StudentRepository repository) {   // @Autowired optional with one constructor
        this.repository = repository;
    }
}
@Service
public class StudentService {

    private final StudentRepository repository;

    public StudentService(StudentRepository repository) {   // @Autowired optional with one constructor
        this.repository = repository;
    }
}
@Service
public class StudentService {

    private final StudentRepository repository;

    public StudentService(StudentRepository repository) {   // @Autowired optional with one constructor
        this.repository = repository;
    }
}

Field injection (works, but less preferred)

java

@Service
public class StudentService {
    @Autowired
    private StudentRepository repository;
}
@Service
public class StudentService {
    @Autowired
    private StudentRepository repository;
}
@Service
public class StudentService {
    @Autowired
    private StudentRepository repository;
}

Point

Constructor injection

Field injection

Testing

Easy, pass a mock in the constructor

Needs reflection or Spring

Immutability

Fields can be final

Cannot be final

Required dependencies

Clear and enforced

Hidden

Verdict

Recommended

Avoid in new code

Two beans of the same type

java

@Component @Primary
class EmailNotifier implements Notifier { }

@Component
class SmsNotifier implements Notifier { }

@Service
class AlertService {
    AlertService(@Qualifier("smsNotifier") Notifier notifier) { }   // picks SmsNotifier
}
@Component @Primary
class EmailNotifier implements Notifier { }

@Component
class SmsNotifier implements Notifier { }

@Service
class AlertService {
    AlertService(@Qualifier("smsNotifier") Notifier notifier) { }   // picks SmsNotifier
}
@Component @Primary
class EmailNotifier implements Notifier { }

@Component
class SmsNotifier implements Notifier { }

@Service
class AlertService {
    AlertService(@Qualifier("smsNotifier") Notifier notifier) { }   // picks SmsNotifier
}

GROUP 3: WEB AND REST

Annotation

What it does

@RestController

Class handles HTTP requests and returns data (JSON) directly

@RequestMapping

Maps a URL path (class or method level)

@GetMapping

Handles GET requests

@PostMapping

Handles POST requests

@PutMapping

Handles PUT requests

@PatchMapping

Handles PATCH requests

@DeleteMapping

Handles DELETE requests

@PathVariable

Reads a value from the URL path

@RequestParam

Reads a query parameter

@RequestBody

Converts the JSON body into a Java object

@ResponseBody

Writes the return value to the response body

@ResponseStatus

Sets the HTTP status code

@RequestHeader

Reads a header value

@CrossOrigin

Allows cross-origin requests (for example, from a React app)

A full REST controller

java

@RestController
@RequestMapping("/api/students")
public class StudentController {

    private final StudentService service;

    public StudentController(StudentService service) {
        this.service = service;
    }

    @GetMapping
    public List<Student> all() {
        return service.findAll();
    }

    @GetMapping("/{id}")
    public Student one(@PathVariable Long id) {
        return service.findById(id);
    }

    @GetMapping("/search")
    public List<Student> search(@RequestParam String city) {     // /api/students/search?city=Pune
        return service.findByCity(city);
    }

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public Student create(@Valid @RequestBody Student student) {
        return service.save(student);
    }

    @DeleteMapping("/{id}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void delete(@PathVariable Long id) {
        service.delete(id);
    }
}
@RestController
@RequestMapping("/api/students")
public class StudentController {

    private final StudentService service;

    public StudentController(StudentService service) {
        this.service = service;
    }

    @GetMapping
    public List<Student> all() {
        return service.findAll();
    }

    @GetMapping("/{id}")
    public Student one(@PathVariable Long id) {
        return service.findById(id);
    }

    @GetMapping("/search")
    public List<Student> search(@RequestParam String city) {     // /api/students/search?city=Pune
        return service.findByCity(city);
    }

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public Student create(@Valid @RequestBody Student student) {
        return service.save(student);
    }

    @DeleteMapping("/{id}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void delete(@PathVariable Long id) {
        service.delete(id);
    }
}
@RestController
@RequestMapping("/api/students")
public class StudentController {

    private final StudentService service;

    public StudentController(StudentService service) {
        this.service = service;
    }

    @GetMapping
    public List<Student> all() {
        return service.findAll();
    }

    @GetMapping("/{id}")
    public Student one(@PathVariable Long id) {
        return service.findById(id);
    }

    @GetMapping("/search")
    public List<Student> search(@RequestParam String city) {     // /api/students/search?city=Pune
        return service.findByCity(city);
    }

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public Student create(@Valid @RequestBody Student student) {
        return service.save(student);
    }

    @DeleteMapping("/{id}")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void delete(@PathVariable Long id) {
        service.delete(id);
    }
}

@PathVariable vs @RequestParam

Point

@PathVariable

@RequestParam

Where the value is

In the URL path

In the query string

Example URL

/students/5

/students?city=Pune

Typical use

Identify one resource

Filter, sort, paginate

@Controller vs @RestController

Point

@Controller

@RestController

Returns

A view name (HTML page) by default

Data written to the response body

Needs @ResponseBody?

Yes, for JSON

No, it’s built in

Used for

Server-rendered pages

REST APIs

GROUP 4: EXCEPTION HANDLING

Annotation

What it does

@ExceptionHandler

Handles a specific exception

@ControllerAdvice / @RestControllerAdvice

Applies exception handling across all controllers

@ResponseStatus

Maps an exception or method to an HTTP status

java

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(StudentNotFoundException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public Map<String, String> notFound(StudentNotFoundException ex) {
        return Map.of("error", ex.getMessage());
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Map<String, String> invalid(MethodArgumentNotValidException ex) {
        Map<String, String> errors = new HashMap<>();
        ex.getBindingResult().getFieldErrors()
          .forEach(e -> errors.put(e.getField(), e.getDefaultMessage()));
        return errors;
    }
}
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(StudentNotFoundException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public Map<String, String> notFound(StudentNotFoundException ex) {
        return Map.of("error", ex.getMessage());
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Map<String, String> invalid(MethodArgumentNotValidException ex) {
        Map<String, String> errors = new HashMap<>();
        ex.getBindingResult().getFieldErrors()
          .forEach(e -> errors.put(e.getField(), e.getDefaultMessage()));
        return errors;
    }
}
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(StudentNotFoundException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public Map<String, String> notFound(StudentNotFoundException ex) {
        return Map.of("error", ex.getMessage());
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Map<String, String> invalid(MethodArgumentNotValidException ex) {
        Map<String, String> errors = new HashMap<>();
        ex.getBindingResult().getFieldErrors()
          .forEach(e -> errors.put(e.getField(), e.getDefaultMessage()));
        return errors;
    }
}

Benefit: one place for clean, consistent error responses instead of repeated try/catch blocks.

GROUP 5: DATA AND JPA

Annotation

What it does

@Entity

Maps a class to a database table

@Table(name = "...")

Sets the table name

@Id

Marks the primary key

@GeneratedValue

Auto-generates the key

@Column

Customises a column (name, length, nullable, unique)

@OneToMany, @ManyToOne, @OneToOne, @ManyToMany

Defines relationships

@JoinColumn

Defines the foreign key column

@Enumerated

Stores an enum as text or number

@Transient

Excludes a field from persistence

@Query

Writes a custom query on a repository method

java

@Entity
@Table(name = "students")
public class Student {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank
    @Column(nullable = false, length = 100)
    private String name;

    @ManyToOne
    @JoinColumn(name = "course_id")
    private Course course;

    // constructors, getters, setters
}
@Entity
@Table(name = "students")
public class Student {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank
    @Column(nullable = false, length = 100)
    private String name;

    @ManyToOne
    @JoinColumn(name = "course_id")
    private Course course;

    // constructors, getters, setters
}
@Entity
@Table(name = "students")
public class Student {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank
    @Column(nullable = false, length = 100)
    private String name;

    @ManyToOne
    @JoinColumn(name = "course_id")
    private Course course;

    // constructors, getters, setters
}

java

public interface StudentRepository extends JpaRepository<Student, Long> {

    List<Student> findByCity(String city);          // derived query

    @Query("SELECT s FROM Student s WHERE s.name LIKE %:text%")
    List<Student> searchByName(@Param("text") String text);
}
public interface StudentRepository extends JpaRepository<Student, Long> {

    List<Student> findByCity(String city);          // derived query

    @Query("SELECT s FROM Student s WHERE s.name LIKE %:text%")
    List<Student> searchByName(@Param("text") String text);
}
public interface StudentRepository extends JpaRepository<Student, Long> {

    List<Student> findByCity(String city);          // derived query

    @Query("SELECT s FROM Student s WHERE s.name LIKE %:text%")
    List<Student> searchByName(@Param("text") String text);
}

Note: a Spring Data repository interface doesn’t need @Repository because Spring Data detects it, though adding it is harmless.

GROUP 6: TRANSACTIONS

Annotation

What it does

@Transactional

Runs a method inside a database transaction, committing on success and rolling back on failure

@EnableTransactionManagement

Enables transaction support (Spring Boot usually configures it automatically)

java

@Service
public class TransferService {

    private final AccountRepository accounts;

    public TransferService(AccountRepository accounts) { this.accounts = accounts; }

    @Transactional
    public void transfer(Long fromId, Long toId, BigDecimal amount) {
        Account from = accounts.findById(fromId).orElseThrow();
        Account to   = accounts.findById(toId).orElseThrow();
        from.debit(amount);
        to.credit(amount);          // if anything throws, both changes roll back
    }
}
@Service
public class TransferService {

    private final AccountRepository accounts;

    public TransferService(AccountRepository accounts) { this.accounts = accounts; }

    @Transactional
    public void transfer(Long fromId, Long toId, BigDecimal amount) {
        Account from = accounts.findById(fromId).orElseThrow();
        Account to   = accounts.findById(toId).orElseThrow();
        from.debit(amount);
        to.credit(amount);          // if anything throws, both changes roll back
    }
}
@Service
public class TransferService {

    private final AccountRepository accounts;

    public TransferService(AccountRepository accounts) { this.accounts = accounts; }

    @Transactional
    public void transfer(Long fromId, Long toId, BigDecimal amount) {
        Account from = accounts.findById(fromId).orElseThrow();
        Account to   = accounts.findById(toId).orElseThrow();
        from.debit(amount);
        to.credit(amount);          // if anything throws, both changes roll back
    }
}

Rules freshers should remember

Rule

Why it matters

Rollback happens by default for unchecked exceptions (RuntimeException and Error)

Checked exceptions don’t roll back unless you configure rollbackFor

It works through proxies

Calling a @Transactional method from another method in the same class bypasses the proxy, so the transaction may not apply

Use it on public methods in Spring-managed beans

Private methods are not intercepted

Put it on the service layer

Business operations, not controllers, define the transaction boundary

readOnly = true

Useful for read-only methods

GROUP 7: VALIDATION

Add the validation starter dependency. In Spring Boot 3 these live in jakarta.validation.constraints.

Annotation

Checks

@Valid

Triggers validation on an object

@Validated

Spring’s variant, supports validation groups and method-level validation

@NotNull

Not null

@NotBlank

Not null and not only spaces (for strings)

@NotEmpty

Not null and not empty

@Size(min, max)

Length or size limits

@Min / @Max

Numeric limits

@Email

Email format

@Pattern(regexp)

Matches a regular expression

@Positive

Greater than zero

java

public class StudentRequest {

    @NotBlank(message = "Name is required")
    @Size(max = 100)
    private String name;

    @Email(message = "Enter a valid email")
    private String email;

    @Min(value = 18, message = "Age must be at least 18")
    private int age;
}
public class StudentRequest {

    @NotBlank(message = "Name is required")
    @Size(max = 100)
    private String name;

    @Email(message = "Enter a valid email")
    private String email;

    @Min(value = 18, message = "Age must be at least 18")
    private int age;
}
public class StudentRequest {

    @NotBlank(message = "Name is required")
    @Size(max = 100)
    private String name;

    @Email(message = "Enter a valid email")
    private String email;

    @Min(value = 18, message = "Age must be at least 18")
    private int age;
}

java

@PostMapping
public ResponseEntity<Student> create(@Valid @RequestBody StudentRequest request) { ... }
@PostMapping
public ResponseEntity<Student> create(@Valid @RequestBody StudentRequest request) { ... }
@PostMapping
public ResponseEntity<Student> create(@Valid @RequestBody StudentRequest request) { ... }

If validation fails, Spring throws MethodArgumentNotValidException, which your @RestControllerAdvice can turn into a clean 400 response.

GROUP 8: PROPERTIES AND PROFILES

Annotation

What it does

@Value("${key}")

Injects a single property value

@ConfigurationProperties(prefix = "...")

Binds a group of properties to a class

@PropertySource

Loads an extra properties file

@Profile("dev")

Activates a bean only for a given profile

java

// application.properties:  app.name=VibrantDemo
@Value("${app.name}")
private String appName;
// application.properties:  app.name=VibrantDemo
@Value("${app.name}")
private String appName;
// application.properties:  app.name=VibrantDemo
@Value("${app.name}")
private String appName;

java

@Configuration
@ConfigurationProperties(prefix = "app.mail")
public class MailProperties {
    private String host;
    private int port;
    // getters and setters
}
@Configuration
@ConfigurationProperties(prefix = "app.mail")
public class MailProperties {
    private String host;
    private int port;
    // getters and setters
}
@Configuration
@ConfigurationProperties(prefix = "app.mail")
public class MailProperties {
    private String host;
    private int port;
    // getters and setters
}

java

@Profile("dev")
@Bean
public DataSource devDataSource() { ... }
@Profile("dev")
@Bean
public DataSource devDataSource() { ... }
@Profile("dev")
@Bean
public DataSource devDataSource() { ... }

Security habit: keep passwords and keys out of source code. Use environment variables or a secrets manager, and don’t commit them to GitHub.

GROUP 9: SCHEDULING, ASYNC AND MISC

Annotation

What it does

@EnableScheduling + @Scheduled

Runs a method on a schedule

@EnableAsync + @Async

Runs a method in a separate thread

@EnableCaching + @Cacheable

Caches method results

@Slf4j (Lombok)

Creates a log field for logging

@Data, @Getter, @Setter, @Builder (Lombok)

Generates boilerplate code

java

@Component
public class ReportJob {
    @Scheduled(cron = "0 0 9 * * *")      // every day at 9:00
    public void sendDailyReport() { ... }
}
@Component
public class ReportJob {
    @Scheduled(cron = "0 0 9 * * *")      // every day at 9:00
    public void sendDailyReport() { ... }
}
@Component
public class ReportJob {
    @Scheduled(cron = "0 0 9 * * *")      // every day at 9:00
    public void sendDailyReport() { ... }
}

Remember to add @EnableScheduling on a configuration or main class.

GROUP 10: TESTING

Annotation

What it does

@SpringBootTest

Loads the full application context for an integration test

@WebMvcTest(Controller.class)

Tests only the web layer

@DataJpaTest

Tests only the JPA layer with an in-memory database

@MockBean / @MockitoBean

Replaces a bean with a mock (newer Spring Boot versions prefer @MockitoBean, so check your version)

@Test

Marks a JUnit test method

@BeforeEach

Runs before every test

java

@WebMvcTest(StudentController.class)
class StudentControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean   // or @MockitoBean in newer versions
    private StudentService service;

    @Test
    void returnsStudent() throws Exception {
        when(service.findById(1L)).thenReturn(new Student(1L, "Asha"));
        mockMvc.perform(get("/api/students/1"))
               .andExpect(status().isOk());
    }
}
@WebMvcTest(StudentController.class)
class StudentControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean   // or @MockitoBean in newer versions
    private StudentService service;

    @Test
    void returnsStudent() throws Exception {
        when(service.findById(1L)).thenReturn(new Student(1L, "Asha"));
        mockMvc.perform(get("/api/students/1"))
               .andExpect(status().isOk());
    }
}
@WebMvcTest(StudentController.class)
class StudentControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean   // or @MockitoBean in newer versions
    private StudentService service;

    @Test
    void returnsStudent() throws Exception {
        when(service.findById(1L)).thenReturn(new Student(1L, "Asha"));
        mockMvc.perform(get("/api/students/1"))
               .andExpect(status().isOk());
    }
}

A COMPLETE MINI EXAMPLE: HOW THE ANNOTATIONS WORK TOGETHER




CHEAT SHEET: 40 SPRING BOOT ANNOTATIONS IN ONE TABLE

#

Annotation

Layer

One-line meaning

1

@SpringBootApplication

Setup

Main class: config + auto-config + scan

2

@EnableAutoConfiguration

Setup

Auto-configure from dependencies

3

@ComponentScan

Setup

Where to look for components

4

@Configuration

Setup

Class that defines beans

5

@Bean

Setup

Method that creates a bean

6

@Component

Stereotype

Generic managed class

7

@Service

Stereotype

Business logic class

8

@Repository

Stereotype

Data access class

9

@Controller

Web

MVC controller (views)

10

@RestController

Web

REST controller (JSON)

11

@Autowired

DI

Inject a dependency

12

@Qualifier

DI

Pick a specific bean

13

@Primary

DI

Default bean

14

@Lazy

DI

Create when needed

15

@Scope

DI

Bean scope

16

@PostConstruct

Lifecycle

Run after initialisation

17

@RequestMapping

Web

Map a URL

18

@GetMapping

Web

Handle GET

19

@PostMapping

Web

Handle POST

20

@PutMapping

Web

Handle PUT

21

@DeleteMapping

Web

Handle DELETE

22

@PathVariable

Web

Value from the path

23

@RequestParam

Web

Query parameter

24

@RequestBody

Web

JSON body to object

25

@ResponseStatus

Web

Set HTTP status

26

@CrossOrigin

Web

Allow cross-origin calls

27

@RestControllerAdvice

Exceptions

Global error handling

28

@ExceptionHandler

Exceptions

Handle a specific exception

29

@Entity

JPA

Class maps to a table

30

@Id

JPA

Primary key

31

@GeneratedValue

JPA

Auto-generated key

32

@Column

JPA

Column settings

33

@OneToMany / @ManyToOne

JPA

Relationships

34

@Query

JPA

Custom query

35

@Transactional

Transaction

Commit or rollback as one unit

36

@Valid

Validation

Trigger validation

37

@NotBlank

Validation

Text must not be blank

38

@Value

Config

Inject a property

39

@Profile

Config

Environment-specific bean

40

@SpringBootTest

Testing

Full integration test

ANNOTATION INTERVIEW QUESTIONS FOR FRESHERS

Question

Short answer

What is @SpringBootApplication?

A convenience annotation combining @Configuration, @EnableAutoConfiguration and @ComponentScan.

@Component vs @Service vs @Repository?

All register beans. @Service marks business logic, @Repository marks data access and adds exception translation.

@Controller vs @RestController?

@RestController is @Controller plus @ResponseBody, so methods return data (JSON) directly.

What does @Autowired do?

Tells Spring to inject a matching bean. Constructor injection is preferred.

What if two beans match?

Use @Qualifier or mark one @Primary.

@PathVariable vs @RequestParam?

Path value (/students/5) vs query parameter (/students?city=Pune).

What does @RequestBody do?

Converts the request JSON into a Java object.

What is @Transactional?

Runs a method in a transaction that commits on success and rolls back on failure (by default for runtime exceptions).

Why might @Transactional not work?

Self-invocation within the same class, private methods, or a bean not managed by Spring.

@Valid vs @Validated?

@Valid is the standard annotation. @Validated is Spring’s variant that adds validation groups.

What is @ControllerAdvice?

A class that handles exceptions globally for all controllers.

What is @Bean vs @Component?

@Component marks a class you write. @Bean marks a method that creates an object, useful for third-party classes.

What does @Entity do?

Maps a class to a database table through JPA.

What is auto-configuration?

Spring Boot configures beans automatically based on libraries on the classpath.

How do you read a property value?

@Value("${key}") for one value, @ConfigurationProperties for a group.

COMMON MISTAKES FRESHERS MAKE WITH SPRING BOOT ANNOTATIONS

Mistake

Result

Fix

Main class in a different package from the code

Beans not found

Keep it in the root package

Forgetting @RestController

404 or whitelabel page

Add the annotation

Forgetting @RequestBody

Fields are null

Add @RequestBody for JSON input

Forgetting @Valid

Validation never runs

Add @Valid before @RequestBody

Using @Autowired on fields everywhere

Hard to test

Use constructor injection

Calling a @Transactional method from the same class

No transaction

Move it to another bean

Putting business logic in controllers

Messy code

Keep controllers thin

Missing @Entity or @Id

JPA startup errors

Add both

Committing passwords in properties

Security risk

Use environment variables

Memorising names without understanding

Fails follow-ups

Explain with the request flow

14-DAY SPRING BOOT ANNOTATIONS PLAN

Day

Focus

Task

1

Setup

Create a project, understand @SpringBootApplication

2

Stereotypes

Build a controller, service and repository

3

Dependency injection

Practise constructor injection, @Qualifier, @Primary

4

REST mappings

Write GET, POST, PUT and DELETE endpoints

5

Request data

Practise @PathVariable, @RequestParam, @RequestBody

6

JPA basics

Create an entity and a JpaRepository

7

Relationships

Add a @ManyToOne and test it

8

Validation

Add @Valid rules and test bad input

9

Exception handling

Build a @RestControllerAdvice

10

Transactions

Write a @Transactional transfer method and test the rollback

11

Properties and profiles

Use @Value, @ConfigurationProperties and a profile

12

Testing

Write a @WebMvcTest and a @DataJpaTest

13

Interview practice

Answer the table above aloud

14

Mini project

Combine everything in a small CRUD API with a README

MYTH VS REALITY

Myth

Reality

“There are hundreds of annotations I must memorise.”

About 40 cover most fresher projects and interviews.

“@Autowired on fields is the standard.”

Constructor injection is the recommended style.

“@Service does something magical.”

It mainly documents the role. The bean creation comes from @Component.

“@Transactional always works.”

It depends on proxies, so call patterns matter.

“Annotations replace understanding.”

Interviewers ask why and how, not just what.

“Lombok is mandatory.”

It’s optional. Know what it generates.

HOW VIBRANTMINDS HELPS FRESHERS MASTER SPRING BOOT

VibrantMinds Technologies Pvt. Ltd. is a Pune-based IT training and placement support company. If you searched for VibrantMinds or VibrantMinds Technologies, here is what it offers:

  • Full Stack Java Development (about 4 to 6 months): Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation. Please check the candidate portal for the latest syllabus and tools.

  • Software Testing (Manual + Automation), Core Java and Python & Data Science for other career paths

  • Project practice: Build Spring Boot projects you can host on GitHub and explain confidently

  • Interview preparation: Technical rounds, project rounds, HR rounds, aptitude, communication and mock interviews

  • Placement support: Screening, drive coordination and interview support. Check https://candidates.vibrantminds.in/ for current openings.

  • Free WhatsApp job alert groups for fresher IT jobs, campus drives and walk-in alerts

  • Honesty first: VibrantMinds offers placement support, not a guaranteed job, and no legitimate recruiter should ask you to pay to be interviewed.

VibrantMinds works as a talent ecosystem connecting candidates, colleges and companies, with 1900+ partner colleges and 600+ hiring companies. More fresher job guidance: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026

VIBRANTMINDS COURSES AT A GLANCE

Course

Duration

Key topics

Full Stack Java Development

4 to 6 months

Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation

Software Testing (Manual + Automation)

2 to 5 months

Test cases, STLC, bug tracking, SQL, Selenium basics

Core Java

1 to 2 months

Syntax, OOP, collections, exceptions, strings

Python & Data Science

2 to 4 months

Python basics, data handling, analysis fundamentals

Fees, syllabus and batch dates are on https://candidates.vibrantminds.in/. Please confirm them directly before enrolling.

THE VIBRANTMINDS PLACEMENT PIPELINE: SIX STEPS




REAL OUTCOMES: WHAT TO EXPECT AND WHAT NOT TO

Past students have shared positive feedback about the training and support, and have gone on to roles at companies such as Aress Software and Education Technologies, Saama Technologies and Three M Software. Results vary by candidate, skill level, effort and market conditions, so please confirm details directly with the VibrantMinds team. No one can honestly promise a guaranteed job.

JOIN FREE VIBRANTMINDS WHATSAPP GROUPS: FREE IT JOB UPDATES FOR JAVA FRESHERS IN PUNE AND INDIA

Looking for free WhatsApp groups, free IT job WhatsApp groups, a Java WhatsApp group for freshers or a job updates WhatsApp group in India? The VibrantMinds groups share fresher IT openings, campus drives, walk-in interview alerts and interview preparation updates, free of charge. Join whichever group has space. All three carry the same type of updates.

Group

What it offers

Link

VibrantMinds Fresher IT Jobs, Group 1

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/CUCS1derlmTFee2c9dyUHd

VibrantMinds Fresher IT Jobs, Group 2

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/FvMf1fGYQYnHppQ8AwFX40

VibrantMinds Fresher IT Jobs, Group 3

Fresher openings, campus drives, walk-in alerts

https://chat.whatsapp.com/I7RNnGMkb2L8S8HibdyWpQ

Never pay to apply. Legitimate recruiters do not charge candidates for tests, interviews or offer letters. Do not share sensitive personal or financial details in any group chat.

FREQUENTLY ASKED QUESTIONS

1. What are the most important Spring Boot annotations for freshers?
@SpringBootApplication, @RestController, @Service, @Repository, @Autowired (or constructor injection), @GetMapping, @PostMapping, @PathVariable, @RequestParam, @RequestBody, @Entity, @Id, @Transactional, @Valid, @Value and @SpringBootTest. Learn them by layer using the cheat sheet above.

2. What is the difference between @Component, @Service and @Repository?
All three register a class as a Spring bean. @Component is generic, @Service marks business logic and @Repository marks data access and also translates persistence exceptions into Spring’s exception hierarchy. Use the most specific one so the role of each class is clear.

3. How does @Transactional work in Spring Boot for beginners?
It wraps a method in a database transaction through a proxy: if the method completes normally the changes are committed, and if a runtime exception occurs they are rolled back. It can fail to apply when you call the method from within the same class, use a private method or the class isn’t a Spring bean.

4. How do I use @Valid and @NotBlank for validation in Spring Boot?
Add the validation starter, put constraints such as @NotBlank, @Email and @Min on your request class fields, and add @Valid before @RequestBody in the controller. Invalid input throws MethodArgumentNotValidException, which you can convert into a clean 400 response with @RestControllerAdvice.

5. Is there a free WhatsApp group for Java freshers in Pune?
Yes. VibrantMinds runs free fresher IT job WhatsApp groups that share Java and other IT openings, campus drives and walk-in alerts. Join through the links above, and always verify a job post and never pay to apply.

CONCLUSION: LEARN SPRING BOOT ANNOTATIONS BY LAYER

The easiest way to master Spring Boot annotations is to stop memorising a long list and learn them by layer: setup, web, service, data, validation and testing. Build a small CRUD API, add each annotation when you need it, explain the request flow aloud and use the cheat sheet and 14-day plan to revise. Prefer constructor injection, understand how @Transactional really works and keep your controllers thin.

If you’re in Pune and want structured Java and Spring Boot training with real project practice, interview preparation and placement support, VibrantMinds Technologies is here to help.

Call to action:

VISIT OR CONTACT VIBRANTMINDS IN PUNE

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved

Office Address

Viva Academy Building, Near St. Mary's Church & Petrol Pump Mumbai-Bangalore Highway, Warje, near to Karvenagar, Pune, Maharashtra 411058

Phone Number

+91 95035 79517

© 2025 VibrantMinds Technologies Pvt. Ltd All Right Reserved