<bean id="iBuyServiceImpl" class="com.example.demo.ioc.service.IBuyServiceImpl">
<property name="ibuyDao" ref="ibuyDaoImpl"></property>
</bean>
public class IBuyServiceImpl implements IBuyService {
private IBuyDao ibuyDao;
public void setIbuyDao(IBuyDao ibuyDao) {
this.ibuyDao = ibuyDao;
}
public void buysomething(String name) {
// TODO Auto-generated method stub
ibuyDao.buysomething(name);
}
}
<bean id="iBuyServiceImpl" class="com.example.demo.ioc.service.IBuyServiceImpl">
<constructor-arg name="ibuyDao" ref = "ibuyDaoImpl"></constructor-arg>
</bean>
public class IBuyServiceImpl implements IBuyService {
private IBuyDao ibuyDao;
public IBuyServiceImpl(IBuyDao ibuyDao) {
super();
this.ibuyDao = ibuyDao;
}
public void buysomething(String name) {
// TODO Auto-generated method stub
ibuyDao.buysomething(name);
}
}
网友评论