<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="personDao" class="net.itdos.dao.impl.PersonDaoBean"></bean>
<bean id="personService" class="net.itdos.service.impl.PersonServiceBean">
<constructor-arg index="0" type="net.itdos.dao.PersonDao" ref="personDao"></constructor-arg>
<constructor-arg index="1" value="XXX"></constructor-arg>
</bean>
</beans>
package net.itdos.service.impl;
import net.itdos.dao.PersonDao;
import net.itdos.service.PersonService;
public class PersonServiceBean implements PersonService {
public PersonServiceBean(PersonDao personDao, String name) {
super();
this.personDao = personDao;
this.name = name;
}
private PersonDao personDao;
private String name;
public void save(){
System.out.println(name);
personDao.save();
}
}