为了账号安全,请及时绑定邮箱和手机立即绑定

spring配置文件的一点小问题

spring配置文件的一点小问题

ibeautiful 2019-03-03 04:04:58
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,请问是怎么回事看到了,在另外的配置文件里面
查看完整描述

2 回答

?
慕沐林林

TA贡献2016条经验 获得超9个赞

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

查看完整回答
反对 回复 2019-03-10
?
智慧大石

TA贡献1946条经验 获得超3个赞

ref local=“XXXXX”为调用本配置文件内的BEAN。
ref bean 是寻找全局中的 bean; ref local 是寻找本 xml 文件中的 bean

你那些个ssmDao,ssmSqlDao什么的那些个BEAN应该都要有的,看一看你这个配置文件的上下文,

或是看看有没有定义一个像是PublicDAO的BEAN,再从别的配置文件里继承了这个PublicDAO BEAN。

查看完整回答
反对 回复 2019-03-10
  • 2 回答
  • 0 关注
  • 528 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信