Imagine you are developing a complex Spring Boot application with custom beans, controllers, services, and repositories. How would you effectively utilize different annotations for a clean and maintainable code structure?

  • @Component for beans, @Controller for web controllers, @Service for business logic, and @Repository for data access.
  • @SpringBootApplication for all components.
  • @Entity for beans, @RestController for web controllers, @Service for business logic, and @Resource for data access.
  • @Configuration for all components.
In a complex Spring Boot application, proper annotation usage is crucial for clean and maintainable code. Use @Component for general beans, @Controller for web controllers, @Service for business logic, and @Repository for data access. This follows the recommended Spring Boot convention, ensuring a clear and structured codebase. The other options mix annotations inappropriately or use annotations that don't align with their intended purposes.
Add your answer
Loading...

Leave a comment

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