package com.bebig.dao.impl;
import com.bebig.dao.UserDAO;
import com.bebig.model.User;
//數(shù)據(jù)訪問接口的實現(xiàn)
public class UserDAOImpl implements UserDAO
{
private int daoId;
private String daoStatus;

public int getDaoId()
{
return daoId;
}

public void setDaoId(int daoId)
{
this.daoId = daoId;
}

public String getDaoStatus()
{
return daoStatus;
}

public void setDaoStatus(String daoStatus)
{
this.daoStatus = daoStatus;
}
@Override
public void save(User u)
{
System.out.println("a user saved!");
System.out.println("daoId="+this.getDaoId());
System.out.println("daoStatus="+this.getDaoStatus());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- a service object; we will be profiling its methods -->
<bean name="u" class="com.bebig.dao.impl.UserDAOImpl">
<!-- 通過property來指定屬性的初始值 -->
<property name="daoId" value="100"></property>
<property name="daoStatus" value="best"></property>
</bean>
<bean id="userService" class="com.bebig.service.UserService">
<constructor-arg>
<ref bean="u" />
</constructor-arg>
</bean>
</beans>
