service.impl裡面是這麼寫的
public class ServiceImpl implements Service{
private Dao dao;
public String getDao(){
return dao.getDao();
}
}
下面是dao的代碼
public interface Dao {
public String getDao();
}
下面是dao.impl代碼
public class DaoImpl implements Dao{
public String getDao(){
//方法
}
}
下面是dao.impl1代碼
public class DaoImpl1 implements Dao{
public String getDao(){
//方法
}
}
我怎麼能更改一個配置文件改變獲取那個dao.impl裡面的方法?這個代碼應該怎麼修改?求大神幫忙~~~~~~
<!--配置bean,配置後該類由spring管理-->
<bean name="springAction" class="com.bless.springdemo.action.SpringAction">
<!--(1)依賴注入,配置當前類中相應的屬性-->
<property name="springDao" ref="springDao"></property>
</bean>
<bean name="DaoImpl" class="com.bless.springdemo.dao.impl.DaoImpl">
<bean name="DaoImpl1" class="com.bless.springdemo.dao.impl.DaoImpl1">
<bean name="ServiceImpl" class="com.bless.springdemo.dao.impl.ServiceImpl">
<property name="dao" ref="DaoImpl"></property> <!--改成DaoImpl1就是另一個了-->
</bean>