spring配置文件的一点小问题

public class SsmServiceImpl implements ISsmService {

private ISsmDao ssmDao;
private ISsmSqlDao ssmSqlDao;
private ISeqService seqService;
}
在一个类中定义了3个接口类型,然后就是get,set方法了

在配置文件中
<bean id="ssmServiceTarget" class="com.longtop.ssm.SsmServiceImpl">
<property name="ssmDao">
<ref bean="ssmDao"/>
</property>
<property name="ssmSqlDao">
<ref bean="ssmSqlDao"/>
</property>
<property name="seqService">
<ref local="seqService"/>
</property>
</bean>
这样写,<ref local="seqService"/>这个是哪里来的,理论上,这个当属性来设置,应该是给这个赋值啊,应该用value,而且我根本没有叫ssmDao的bean,请问是怎么回事
看到了,在另外的配置文件里面

ibeautiful
浏览 532回答 2
2回答

慕沐林林

<bean id="seqService"class="com.xxx.ISeqService "><property name="sessionFactory"><ref local="mySessionFactory" /></property></bean>前面定义一个bean的id是seqService后面就可以用<ref local="seqService"/> 你找下你的spring配置文件应该有我上面那句话的

智慧大石

ref local=“XXXXX”为调用本配置文件内的BEAN。ref bean 是寻找全局中的 bean; ref local 是寻找本 xml 文件中的 bean你那些个ssmDao,ssmSqlDao什么的那些个BEAN应该都要有的,看一看你这个配置文件的上下文,或是看看有没有定义一个像是PublicDAO的BEAN,再从别的配置文件里继承了这个PublicDAO BEAN。
打开App,查看更多内容
随时随地看视频慕课网APP