Spring ApplicationContextAware和事务配置问题
这个问题困扰着我几天了.....
//action类
public class BaseAction extends ActionSupport {
public ServiceFacade facade; //外观类
public ServiceFacade getFacade() {
return facade;
}
public void setFacade(ServiceFacade facade) {
this.facade = facade;
}
}
//外观类
public class ServiceFacade implements ApplicationContextAware {
private ApplicationContext ac;
public ApplicationContext getAc() {
return ac;
}
public void setApplicationContext(ApplicationContext applicationContext){
this.ac = applicationContext;
}
}
//业务层
....
spring配置
<!-- action配置 -->
<bean id="baseAction" class="cn.warehouse.action.BaseAction">
<property name="facade" ref="facade"></property>
</bean>
<!-- 外观类 -->
<bean id="facade" class="cn.warehouse.facade.ServiceFacade"></bean>
<!-- 业务层 -->
........
现在问题是声明式事务中
1. <!-- 声明式事务在业务层 -->
这里完美运行程序,并已经查询到数据到页面(一切正常)
<aop:config>
<aop:pointcut expression="execution(* cn.warehouse.service.impl.*.*(..))" id="bizMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethod"/>
</aop:config>
2.1. <!-- 声明式事务在外观类 -->
报错了
<aop:config>
<aop:pointcut expression="execution(* cn.warehouse.facade.*.*(..))" id="bizMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethod"/>
</aop:config>
异常:
严重: Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseAction' defined in class path resource [applicationContext-action.xml]: Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0 implementing
org.springframework.context.ApplicationContextAware,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to&n