View video tutorial

SPRING BOOT Annotation

SPRING BOOT

Spring Boot annotations are special tags used in Java classes to reduce XML configuration.

Spring Boot Annotations:


➔ Spring Boot annotations are markers used in Java classes that provide special instructions to the Spring Framework, allowing the framework to use class-based configuration for various components of the application without additional XML-based configuration.

➔ Spring Boot simplifies the process of application configuration by using annotations on Java classes, methods, and variables.

➔ Annotations help developers quickly configure applications and reduce the time to implement various features.

➔ Developers can avoid XML-based configuration by using Spring Boot annotations.

Key Concepts of Annotations:


➔ Annotation without XML helps developers configure applications directly within Java classes, making them cleaner and more manageable.

➔ In Spring Boot, much of the configuration happens automatically with the help of the @EnableAutoConfiguration annotation.

➔ Spring Boot detects and registers annotated classes by automatic component scanning.

➔ Spring Boot scans the annotated classes with any dependencies and creates objects at runtime.

Common Spring Boot Annotations:

Spring boot have many different types of annotations , each for a different purposes and functions. Annotations can be classified based on their function or the level at which they operate.

Application Level Annotations:


➔ @Configuration:

➔ @EnableAutoConfiguration:

➔ @ComponentScan:

Core Annotations:


➔ @Component:

➔ @Service:

➔ @Autowired:

➔ @Bean:

Web and RESTful API annotations:


➔ @Controller:

➔ @RestController:

➔ @RequestMapping:

➔ @GetMapping:

➔ @PostMapping:

➔ @PutMapping:

➔ @DeleteMapping:

➔ @PathVariable:

➔ @RequestParam:

➔ @RequestBody:

Data model and Persistence Annotations:


➔ @Entity:

➔ @Table:

➔ @Id:

➔ @GeneratedValue:

➔ @Column:

➔ @OneToMany:

➔ @ManyToOne:

➔ @ManyToMany:

➔ @OneToOne:

➔ @Repository:

➔ @Query:

Data Validation / Bean Validation (via Hibernate) Annotations:


➔ @NotNull:

➔ @NotBlank:

➔ @Size:

➔ @Min:

➔ @Max:

➔ @Email: