1 External bean
public class UserDao{
private String username;
public void SetName(String name){
this.username = name;
}
public void add(){
System.out.println("hello");
}
}
public class UserService{
private UserDao userdao;
public void setUserdao(UserDao userdao){
this.userdao = userdao;
}
}
Injection of external beans:
<bean id = "userService" class="com.glp.UserService">
<property name = "userDao" ref ="userDao"></property>
</bean>
<bean id = "userDao" class="com.glp.UserDao"></bean>
2 Internal Bean
Injection of internal Bean:
<bean id = "userService" class="com.glp.UserService">
<property name = "userDao">
<bean id = "userDao" class="com.glp.UserDao">
<property name = "username" value="glp"></property>
</bean>
</property>
</bean>
3 Cascade assignment
It is somewhat different from the external Bean. When the external Bean is introduced, attributes are set for the external Bean.
<bean id = "userService" class="com.glp.UserService">
<property name = "userDao" ref="userDao"></property>
</bean>
<bean id = "userDao" class="com.glp.UserDao">
<property name = "username" value="glp"></property>
</bean>