1. Mixing of classes:
Configuration in the configuration file:
<bean id= "A" class= "COM.AB.CC.A"/>
Configuration in a class
@Autowired
A;
The benefits of this can be reduced Get/set method
[email protected] and @resource the difference
Autowired By default is automatically assembled according to Bytype, so there are multiple types of XML or annotation of a class when the error, you can add @qualifier annotations, specify the name. This is spring comes with, when the frame, to spring;
@Autowired
@Qualifier ("Userserviceimpl")
Public Iuserservice UserService;
Or
@Autowired
public void Setuserdao (@Qualifier ("Userdao") Userdao Userdao) {
This.userdao = Userdao;
}
Resource by default is automatically assembled according to the byname, this is the Java comes with, when changing the frame, do not need spring.
@Resource
Private car car;
3. In the XML configuration file, the previous <context:component-scan/> configuration will be overwritten by the <bean id= ""/> Configuration in the following case, if there is the same configuration
XML configuration and autowired blending in spring