Spring Boot Annotations - Explained
@SpringBootApplication
Combines @Configuration, @EnableAutoConfiguration, and @ComponentScan. Used in the main class to
bootstrap the Spring Boot application.
@RestController
Used to create RESTful web services. It combines @Controller and @ResponseBody.
@Controller
Marks a class as a web controller, typically returning views.
@RequestMapping
Maps HTTP requests to handler methods of MVC and REST controllers.
@GetMapping / @PostMapping / @PutMapping / @DeleteMapping
Specialized versions of @RequestMapping for HTTP methods.
@PathVariable
Binds a method parameter to a URI template variable.
@RequestBody
Binds the body of a request to a method parameter.
@ResponseBody
Indicates that the return value of a method should be used as the response body.
Spring Boot Annotations - Explained
@Autowired
Marks a dependency to be injected by Spring's dependency injection facilities.
@Service
Marks a class as a service provider.
@Repository
Indicates that a class is a repository and may throw database-related exceptions.
@Entity
Marks a class as a JPA entity to be mapped to a database table.
@Id
Specifies the primary key of an entity.
@GeneratedValue
Provides the specification of generation strategies for primary keys.
@Configuration
Indicates that the class can be used by the Spring IoC container as a source of bean definitions.
@Bean
Indicates that a method produces a bean to be managed by the Spring container.
@Component
Spring Boot Annotations - Explained
Indicates that an annotated class is a component. Such classes are considered as candidates for
auto-detection.
@ComponentScan
Configures component scanning directives for use with @Configuration classes.
@EnableAutoConfiguration
Tells Spring Boot to start adding beans based on classpath settings, other beans, and property settings.
@CrossOrigin
Enables cross-origin resource sharing only for specific methods.
@Optional (Java Optional)
A container object which may or may not contain a non-null value. Helps avoid null pointer exceptions.