Spring-IOC annotation properties of injection

Spring annotation attributes injection:

Common variable type (e.g., String, int) and the like directly value ( "value") to.
For some custom objects, usually @ Autowired, @ resource notes, etc.

  1. @Autowired is carried out by the object type assignment, then there will be such a problem, how do how to have two of the same type, this time will be thrown, then you can use annotations @Resource assignment, @ Resource is based on the name of the variable assignment to find and then, so there are more objects of the same type can be used @Resource.
  2. Of course, you can also combine @Qualifier notes at the same time, specify the variable name with @Qualifiter, so that you can assign a find the object, is simply @Resource = @ Autowired + @ Qualifier.
Published 25 original articles · won praise 0 · Views 290

Guess you like

Origin blog.csdn.net/qq_42219004/article/details/105163779