Spring bean init-method中使用ibatis访问数据库
大侠联盟 2016-12-30 10:31:43 我现在有一个java web项目,其中使用到了socket服务,我在spring中配置了这个socket所在类,并将init-method配置为socket服务启动的方法。下面是我spring bean的 配置:
<bean id="socketServlet" parent="transactionProxy" lazy-init="true">
<property name="target">
<bean class="xxx.xxx.xxx.SocketServlet" init-method="init">
<property name="myService" ref="myService"></property>
</bean>
</property>
</bean>
我想在socketServlet 的init方法中访问数据库,使用了另一个bean: myService, 在myService中访问了数据库,项目使用的是ibatis框架,经过调试发现,myService已经成功注入了,但是调用myService方法访问数据库的时候报错,下面是主要报错信息:
nested exception is com.ibatis.sqlmap.client.SqlMapException: There is no statement named basic.queryXXX in this SqlMap.
请问各位高手,我这种方式是否能实现?如果可以,哪里出了问题?