Câu hỏi phỏng vấn Spring
Câu hỏi

What are some of the important S...

Câu trả lời

In my experience with Spring, several annotations are particularly important due to their frequent use and significant role in simplifying Spring application development. Here are some of the key annotations:

  1. @SpringBootApplication - This is a convenience annotation that combines @EnableAutoConfiguration, @ComponentScan, and @Configuration. It's typically used on your main application class to enable a host of default behavior, such as setting up a Spring application context and performing class path scanning[2][7].

  2. @Bean - Used at the method level, this annotation tells Spring that a method will return an object that should be registered as a bean in the Spring application context. It's a fundamental annotation for Java-based configurations[1][4].

  3. @Autowired - This annotation is used to auto-wire bean on the setter method, constructor, a property, or methods with arbitrary names and/or multiple arguments. It's incredibly useful for dependency injection, reducing the need for boilerplate code[1][5].

  4. @Component - This is a generic stereotype annotation indicating that the class is a Spring component. It allows the class to be auto-detected through classpath scanning. It's the base annotation that other stereotype annotations like @Repository, @Service, and @Controller are built upon[1][4].

  5. @Service and @Repository - These are specializations of @Component that indicate the annotated class is a service or a repository, respectively. @Service holds business logic, whereas @Repository is used to abstract access to database repositories[1][4].

  6. @Controller and @RestController - @Controller is used to mark a class as a web controller, capable of hand...

senior

senior

Gợi ý câu hỏi phỏng vấn

middle

What is Controller in Spring MVC framework?

junior

What are benefits of using Spring?

expert

How does autowiring work in Spring?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào