Spring+ibatis整合事务控制配置问题

nxvan 2012-11-06 09:00:19
自己搭建Spring+ibatis+blazeds框架,其他都好了,就是已配置事务控制的service就会报错,,求大家帮忙看一下
这是配置文件
<!-- 针对单一数据源的事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>

<bean id="baseDao" class="com.unit.BaseAction">
<property name="dataSource"><ref local="dataSource" />
</property>
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>

<!-- 配置事务代理的基类,如果子类需要事务处理,一般建议继承该代理,可以将很多通用的方法 -->
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">
PROPAGATION_REQUIRED,-AppException,-PrcException
</prop>
</props>
</property>
</bean>
<bean id="baseService" class="com.unit.BaseService">
<property name="dao">
<ref bean="baseDao" />
</property>
</bean>

<bean id="abstractBaseService" abstract="true" class="com.unit.BaseService">
<property name="dao">
<ref bean="baseDao" />
</property>
</bean>
<bean id="commonSqlExecuteService" parent="baseTransactionProxy" >
<property name="target">
<bean class="com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl" parent="abstractBaseService">
</bean>
</property>
</bean>

这是baseService
public class BaseService {
private BaseAction dao;
public BaseAction getDao() {
return dao;
}
public void setDao(BaseAction dao) {
this.dao = dao;
}
public SqlMapClientTemplate getService(String sevicename){
return dao.getService(sevicename);
}

}

这是baseAction
public  class BaseAction extends SqlMapClientDaoSupport {


public SqlMapClientTemplate getService(String servicename) throws DataAccessException {
ApplicationContext app;
app = new ClassPathXmlApplicationContext("../applicationContext.xml");

return ((BaseAction)app.getBean(servicename)).getSqlMapClientTemplate();

}

}


报错信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonSqlExecuteService' defined in class path resource [../applicationContext.xml]: Cannot create inner bean 'com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl#c9f93f' of type [com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl#c9f93f' defined in class path resource [../applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException
只要不进行事务控制,就可以连接数据库操作,,试过很多办法了,,解决不了,,求大神知道一下
...全文
303 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mswowest 2013-01-22
  • 打赏
  • 举报
回复
同问!!!求大神啊~~~~
nxvan 2012-11-06
  • 打赏
  • 举报
回复
引用 1 楼 fangmingshijie 的回复:
Cannot create inner bean 'com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl#c9f93f' of type [com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl] while setting bean property 'ta……
大侠,请指条明路··怎么才能对这个创建一个事务控制的baseService,,然后所有需要控制的继承就可以了,,感激不尽···
  • 打赏
  • 举报
回复
Cannot create inner bean 'com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl#c9f93f' of type [com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl] while setting bean property 'target'; <bean id="commonSqlExecuteService" parent="baseTransactionProxy" > <property name="target"> <bean class="com.dao.service.serviceimpl.CommonSqlExecuteServiceImpl" parent="abstractBaseService"> </bean> </property> </bean> 不能在一个bean中创建另外一个bean

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧