当前位置:编程学习 > JAVA >>

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

自己搭建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
只要不进行事务控制,就可以连接数据库操作,,试过很多办法了,,解决不了,,求大神知道一下
--------------------编程问答-------------------- 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 --------------------编程问答--------------------
引用 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,,然后所有需要控制的继承就可以了,,感激不尽··· --------------------编程问答-------------------- 同问!!!求大神啊~~~~
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,