问题:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext-service-user.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sqlMapClient is required
Caused by: java.lang.IllegalArgumentException: sqlMapClient is required
我的配置 :
<bean id="[b]sqlMapClient[/b]" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" class="com.tnt.ebr.sys.service.IbatisBaseDao">
<property name="sqlMapClient"><ref local="[b]sqlMapClient[/b]"/></property>
</bean>
<bean id="userService" class="com.tnt.ebr.sys.service.impl.UserServiceImpl">
<property name="dao" ref="[b]baseDao[/b]"></property>
</bean>
IbatisBaseDao.java代码:
public class IbatisBaseDao extends [b]SqlMapClientDaoSupport[/b] {
}
所要引用的代码:
public class UserServiceImpl [u][b]extends SqlMapClientDaoSupport [/b][/u]implements UserService {
protected IbatisBaseDao dao;
只要把extends SqlMapClientDaoSupport 去掉就OK了
问题待续中……
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext-service-user.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sqlMapClient is required
Caused by: java.lang.IllegalArgumentException: sqlMapClient is required
我的配置 :
<bean id="[b]sqlMapClient[/b]" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseDao" class="com.tnt.ebr.sys.service.IbatisBaseDao">
<property name="sqlMapClient"><ref local="[b]sqlMapClient[/b]"/></property>
</bean>
<bean id="userService" class="com.tnt.ebr.sys.service.impl.UserServiceImpl">
<property name="dao" ref="[b]baseDao[/b]"></property>
</bean>
IbatisBaseDao.java代码:
public class IbatisBaseDao extends [b]SqlMapClientDaoSupport[/b] {
}
所要引用的代码:
public class UserServiceImpl [u][b]extends SqlMapClientDaoSupport [/b][/u]implements UserService {
protected IbatisBaseDao dao;
只要把extends SqlMapClientDaoSupport 去掉就OK了
问题待续中……
本文分析了一个关于Spring框架中Bean创建失败的问题,错误发生在名为'userService'的Bean上,原因是初始化过程中抛出了IllegalArgumentException异常,提示sqlMapClient为必需。通过检查配置文件及IbatisBaseDao与UserServiceImpl的实现,发现继承SqlMapClientDaoSupport导致了问题。
1556

被折叠的 条评论
为什么被折叠?



