How does the @Repository annotation in Spring Boot mainly differ from the @Service annotation?

  • @Repository is used for database operations, while @Service is used for business logic.
  • @Service is used for database operations, while @Repository is used for business logic.
  • @Repository is used for managing transactions, while @Service is used for database operations.
  • @Service is used for managing transactions, while @Repository is used for business logic.
The @Repository annotation in Spring Boot is primarily used for database operations and is typically applied to DAO (Data Access Object) classes. It includes functionality related to data access, exception translation, and transactions. On the other hand, @Service is used for defining business logic and typically includes the service layer of an application. @Repository focuses on database-related concerns, while @Service is more about the application's business logic. The other options provide incorrect differentiations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *