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.
Loading...
Related Quiz
- Which of the following is a true statement about transaction management in Spring Data JPA?
- The @Autowired annotation in Spring can be used to autowire bean on the _____
- In Spring Boot, which annotation is used to define a class as a global advice for all controllers?
- A Spring Boot application is facing frequent OutOfMemoryErrors. Describe the steps you would take to diagnose the root cause and mitigate this issue.
- How can you configure different token lifetimes for different OAuth2 clients in a Spring Boot application?