实现service接口的业务类
构造方法注入
/**
* @author DELL
* 业务层实现类
*/
public class AccountServiceImpl implements IAccountService {
/**
* 经常变化的数据,并不适合构造方法注入
*/
private String name;
private Integer age;
private Date bitthday;
public AccountServiceImpl(String name, Integer age, Date bitthday) {
this.name = name;
this.age = age;
this.bitthday = bitthday;
}
@Override
public void saveAccount() {
System.out.println("service中的saveAccount方法执行了...");
}
}
bean.xml中的配置
<!-- 构造函数注入 -->
<bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl">
<constructor-arg name="name" value="张三"></constructor-arg>
<constructor-arg name="age" value="18"></constructor-arg>
<constructor-arg name="bitthday" ref="now"></constructor-arg>
</bean>
<bean id="accountDao" class="com.itheima.dao.impl.AccountDaoImpl"