Sometimes, when we inject a dependency into the DAO layer, service layer, and action, we often prompt for null pointer exceptions, that is, injection failures. ..
This is every bit abnormal, normal use ~ ~ What is going on ... The reasons are as follows:
In the case of dependency injection, the injection of the DAO layer class is not the same as the action. A little bit different.
Our example explains the subtle differences between the two injections:
Example of a DAO layer injection:
<bean id= "Loginregistserviceimpl" class= "Com.serviceImpl.LoginRegistServiceImpl" >
<constructor-arg Name= "Udao" ><ref bean= "Userdaoimpl"/></constructor-arg>
</bean>
<bean id= " ServiceManager "class=" Com.serviceImpl.ServiceManager ">
<property name=" LRS "><ref bean=" Loginregistserviceimpl "/></property>
</bean>
Take a look at the injection of action:
<bean id= "loginregistaction" class= "com.action.LoginRegistAction" >
<property name= "ServiceManager" ><ref bean= "ServiceManager"/></property>
</bean>
The focus is on: [HTML] view plain copy <property name= "ServiceManager" ><ref bean= "ServiceManager"/></ Property>
In action injection, you must require that the name of the variable defined by the action be consistent with the ID name of the injected bean, and no injection fails ~ ~ ~