<?xml version="1.0" encoding="UTF-8"?>
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/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byType" >
<!-- class="org.springframework.jdbc.datasource.DriverManagerDataSource" -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:config.xml</value>
</property>
<property name="dataSource" ref="dataSource">
</property>
</bean>
<!-- 根据sqlMapClien创建一个SqlMapClient模版类-->
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<bean id="LoginAction" class="com.zyoung.actions.Login">
<property name="userService" ref="userService"></property>
</bean>
<!-- bean中的class为实现接口的类;property的name为类中引用的属性名称;ref为spring注册的名称,如上面的client-->
<bean id="userDao"
class="com.zyoung.dao.impl.UserDao">
<property name="client" ref="sqlMapClientTemplate" />
</bean>
<bean id="userService" class="com.zyoung.service.impl.UserService">
<property name="userDao" ref="userDao"></property>
</bean>
<tx:advice id="txadvice" transaction-manager="Manager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="point" expression="execution(* com.zyoung.service.impl.UserService.insertUser(..))" />
<aop:advisor pointcut-ref="point" advice-ref="txadvice"/>
</aop:config>
<bean id="Manager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
[color=red]<!-- Introducation实验-->
<bean id="Iother" class="introduction.OtherImpl"/>
<bean id="advisorss" class="org.springframework.aop.support.DefaultIntroductionAdvisor">
<constructor-arg index="0">
<ref bean="Iother"/>
</constructor-arg>
<constructor-arg index="1">
<value>introduction.IOther</value>
</constructor-arg>
</bean>
<bean id="poxyOther" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.zyoung.service.IUserService</value>
</property>
<property name="target">
<ref bean="userService"/>
</property>
<property name="interceptorNames">
<list>
<value>advisorss</value>
</list>
</property>
</bean>[/color]
错误:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dataSource': Bean with name 'dataSource' has been injected into other beans [sqlMapClient, Manager] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). 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.
.....
我没加入
<!-- Introducation实验--> 以下配置时没报错,找了半天不知道哪循环依赖了,本人刚刚学spring 忘各位大侠详细解答,谢谢了