Annotation in SpringBoot
*1.@SpringBootApplication *is a key annotation in Spring Boot, used to mark the main class of a Spring Boot application. 2.@ConfigurationIndicates that the class can be used by the Spring IoC container as a source of bean definitions. 3.@EnableAutoConfigurationTells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if Spring MVC is on the classpath, it auto-configures a web application. 4.@ComponentScanTells Spring to look for other components, configurations, and services in the package, allowing it to find the controllers and other beans you create. ** 5.@Controller** is a Spring annotation used to define a web controller in a Spring MVC application. It tells Spring that the class is a web controller, which will handle HTTP requests (like GET and POST) and return views (usually HTML pages using Thymeleaf, JSP, etc.). When to use @Controller: When you're building web applications with Spring MVC. When you want to return a view name (like a .html page) instead of raw data (for that, you'd use @RestController). 6.@GetMapping is a Spring annotation used to handle HTTP GET requests in a Spring MVC application. 7.@PostMapping is used in Spring to handle HTTP POST requests, typically for form submissions or sending data to the server (like in APIs). 8.@SessionAttributes is a Spring MVC annotation used to store model attributes in the HTTP session, so they can be accessed across multiple requests (e.g., across multiple pages or forms). Why use it? Normally, attributes you add to the Model are only available for one request. @SessionAttributes lets you persist specific model attributes in the user's session — useful for things like: Multi-page forms Keeping user info like username or email during login sessions 9.@RestController is a Spring annotation used to create RESTful web services. It tells Spring that the class will handle HTTP requests and return data (usually JSON) directly instead of rendering a view (like HTML). 10.@CrossOrigin is a Spring annotation that enables Cross-Origin Resource Sharing (CORS), which allows your backend to accept requests from a different origin (domain, port, or protocol) — very useful when your frontend and backend are hosted separately. 11.@Entity is a JPA (Java Persistence API) annotation used in Spring (and other Java frameworks) to mark a class as a database entity — meaning it's mapped to a table in the database. 12.@id is a JPA annotation used to specify the primary key of an entity (a unique identifier for each record in a database table). 13.@GeneratedValue is a JPA annotation used with @id to specify how the primary key should be generated automatically when a new record is inserted into the database. 14.@ManyToOne is a JPA annotation used to specify a many-to-one relationship between two entities. It indicates that many instances of the current entity are associated with one instance of another entity. 15.@JoinColumn(name = "customer_id"): Specifies the foreign key column in the Order table that references the primary key of Customer. 16.@OneToMany(mappedBy = "customer"): In the Customer entity, this defines the inverse side of the relationship, stating that orders are mapped by the customer field in the Order entity. 17.@Table is a JPA annotation used to specify the details of the database table that an entity class is mapped to. By default, JPA will map an entity to a table with the same name as the class, but with @Table, you can customize the table's name and other properties. Purpose of @Table: Allows you to define the name of the database table. Specify unique constraints on one or more columns. Define the schema if the table belongs to a specific schema in the database. 18.@Repository is a Spring annotation used to define a Data Access Object (DAO) component. It is a specialization of @Component, meaning Spring will automatically detect and register the class as a bean for dependency injection. This annotation is typically used in Spring Data JPA or Spring JDBC to define a class responsible for interacting with the database. 19.@Service **is a Spring annotation used to mark a class as a service layer component. It is a specialization of the @Component annotation, meaning Spring will treat it as a Spring bean and manage its lifecycle (just like any other bean). The service layer typically contains business logic and acts as an intermediary between the controller layer (which handles HTTP requests) and the repository layer (which handles data access). 20.@Autowired** is a Spring annotation used to automatically inject dependencies into a Spring bean. It allows you to wire up your beans without needing to manually instantiate them. Spring will automatically resolve and inject the dependencies based on the type of the bean. 21.@Getter and @setter: Both of these annotations are from Lombok and are used to generate getter and setter methods for the fields in your class

*1.@SpringBootApplication *is a key annotation in Spring Boot, used to mark the main class of a Spring Boot application.
2.@ConfigurationIndicates that the class can be used by the Spring IoC container as a source of bean definitions.
3.@EnableAutoConfigurationTells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if Spring MVC is on the classpath, it auto-configures a web application.
4.@ComponentScanTells Spring to look for other components, configurations, and services in the package, allowing it to find the controllers and other beans you create.
**
5.@Controller** is a Spring annotation used to define a web controller in a Spring MVC application. It tells Spring that the class is a web controller, which will handle HTTP requests (like GET and POST) and return views (usually HTML pages using Thymeleaf, JSP, etc.).
When to use @Controller:
When you're building web applications with Spring MVC.
When you want to return a view name (like a .html page) instead of raw data (for that, you'd use @RestController).
6.@GetMapping is a Spring annotation used to handle HTTP GET requests in a Spring MVC application.
7.@PostMapping is used in Spring to handle HTTP POST requests, typically for form submissions or sending data to the server (like in APIs).
8.@SessionAttributes is a Spring MVC annotation used to store model attributes in the HTTP session, so they can be accessed across multiple requests (e.g., across multiple pages or forms).
Why use it?
Normally, attributes you add to the Model are only available for one request.
@SessionAttributes lets you persist specific model attributes in the user's session — useful for things like:
Multi-page forms
Keeping user info like username or email during login sessions
9.@RestController is a Spring annotation used to create RESTful web services. It tells Spring that the class will handle HTTP requests and return data (usually JSON) directly instead of rendering a view (like HTML).
10.@CrossOrigin is a Spring annotation that enables Cross-Origin Resource Sharing (CORS), which allows your backend to accept requests from a different origin (domain, port, or protocol) — very useful when your frontend and backend are hosted separately.
11.@Entity is a JPA (Java Persistence API) annotation used in Spring (and other Java frameworks) to mark a class as a database entity — meaning it's mapped to a table in the database.
12.@id is a JPA annotation used to specify the primary key of an entity (a unique identifier for each record in a database table).
13.@GeneratedValue is a JPA annotation used with @id to specify how the primary key should be generated automatically when a new record is inserted into the database.
14.@ManyToOne is a JPA annotation used to specify a many-to-one relationship between two entities. It indicates that many instances of the current entity are associated with one instance of another entity.
15.@JoinColumn(name = "customer_id"): Specifies the foreign key column in the Order table that references the primary key of Customer.
16.@OneToMany(mappedBy = "customer"): In the Customer entity, this defines the inverse side of the relationship, stating that orders are mapped by the customer field in the Order entity.
17.@Table is a JPA annotation used to specify the details of the database table that an entity class is mapped to. By default, JPA will map an entity to a table with the same name as the class, but with @Table, you can customize the table's name and other properties.
Purpose of @Table:
Allows you to define the name of the database table.
Specify unique constraints on one or more columns.
Define the schema if the table belongs to a specific schema in the database.
18.@Repository is a Spring annotation used to define a Data Access Object (DAO) component. It is a specialization of @Component, meaning Spring will automatically detect and register the class as a bean for dependency injection. This annotation is typically used in Spring Data JPA or Spring JDBC to define a class responsible for interacting with the database.
19.@Service **is a Spring annotation used to mark a class as a service layer component. It is a specialization of the @Component annotation, meaning Spring will treat it as a Spring bean and manage its lifecycle (just like any other bean). The service layer typically contains business logic and acts as an intermediary between the controller layer (which handles HTTP requests) and the repository layer (which handles data access).
20.@Autowired** is a Spring annotation used to automatically inject dependencies into a Spring bean. It allows you to wire up your beans without needing to manually instantiate them. Spring will automatically resolve and inject the dependencies based on the type of the bean.
21.@Getter and @setter:
Both of these annotations are from Lombok and are used to generate getter and setter methods for the fields in your class.
@Getter: Generates getter methods for all fields.
@setter: Generates setter methods for all fields.
22.@AllArgsConstructor:This annotation, also from Lombok, generates a constructor with arguments for all the fields in your class. It helps in cases where you want to create instances of your class with all properties set at once.
23.@NoArgsConstructor:This annotation is from Lombok. It generates a no-arguments constructor for your class at compile-time. A no-arguments constructor is particularly useful when your class is used with frameworks like Spring, which require a default constructor to instantiate objects using reflection.
24.@JsonIgnoreProperties(ignoreUnknown = true):
This annotation is provided by Jackson, the JSON processor used in Spring applications. It tells Jackson to ignore any unknown properties that are encountered during the deserialization of a JSON object. This is especially useful when you're working with external JSON APIs, or if the structure of your JSON might