Spring Annotations Learning Record


Since Spring 2.0, we began to introduce some notes, in order to simplify the development of Spring. The following Spring will record some of the comments, to facilitate follow-up study to see. When the Spring project, open the automatic scanning function, Spring will be after the start of the project, the entire project to automatically scan, so that the various notes play a relevant role, so as to serve the entire project.

@Repository 

The annotation is used to identify data access layer class (DAO layer) Spring Bean. The annotation can be marked on the DAO classes. It will be noted in the class data access exceptions thrown exception type of encapsulation Spring access data. Spring itself provides a rich and is independent of the access technology specific data structure data access exceptions, for different packages persistence framework thrown exception, such that the frame independent of the underlying abnormality.

@Component   is a generalization of the concept, represent only one component (Bean), may act at any level.

@Service   usually applied in the business layer, but this feature is currently the @Component same.

@Controller   usually applied in the control layer, but present the same function @Component.

@Autowired automatic assembly.


Published 10 original articles · won praise 14 · views 40000 +

Guess you like

Origin blog.csdn.net/cuierdan/article/details/79526254