spring aop配置出错 帮忙检查

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring aop配置出错 帮忙检查相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-autowire="byName"
default-lazy-init="false">

<!--读取驱动信息参数文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/jdbc.properties</value>
</list>
</property>
</bean>
<!-- C3P0 数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="$jdbc.driverClassName" />
<property name="jdbcUrl" value="$jdbc.url" />
<property name="user" value="$jdbc.username" />
<property name="password" value="$jdbc.password" />
</bean>
<!-- - - - - - - spring Transaction Manager - - - - - - - -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<!-- - - - - - - spring Transaction Attribute - - - - - - - -->
<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="* sen.*.*(..)"/>
</tx:attributes>
</tx:advice>
<!--****** weave *********-->
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* *.*(..))" />
<aop:advisor advice-ref="transactionAdvice" pointcut-ref="serviceOperation" />
</aop:config>
<bean id="sqlSessionFactory" class="org.springframework.orm.ibatis3.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:config/ibatisConfig.xml"/>
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="sqlSessionTemplate" class="org.springframework.orm.ibatis3.SqlSessionTemplate">
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>
<bean id="sqlSessionDaoSupport" class="org.springframework.orm.ibatis3.support.SqlSessionDaoSupport" abstract="true"/>
tomcat 启动不起来 [ERROR] 2010-01-18 15:52:40 :Context initialization failed
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dataSource': Bean with name 'dataSource' has been injected into other beans [transactionManager] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.

参考技术A 你的dataSource在一个地方重复注入了
看你的这个地方,你的切面定义在全局。所以这个地方有问题,把下面这段先注释掉,或者把切面精确去找问题。(和上面注入冲突了)
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* *.*(..))" />
<aop:advisor advice-ref="transactionAdvice" pointcut-ref="serviceOperation" />
</aop:config>本回答被提问者采纳

以上是关于spring aop配置出错 帮忙检查的主要内容,如果未能解决你的问题,请参考以下文章

Spring aop 实例(转)

Spring——AOP之Spring1中的配置

spring学习笔记(23)基于tx/aop配置切面增强事务

报错spring实战(第四版)示例代码 ,使用 @DeclareParents 实现aop出错

Spring之AOP【二】

从头认识Spring-3.3 简单的AOP日志实现-增加检查订单功能