<!-- 数据源 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/tempsysdb">
</property>
<property name="username" value="root"></property>
<property name="password" value="123456"></property>
</bean>
<!-- sqlMapClient -->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="classpath:sqlmap-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- end -->
<!-- ****************事务通知(事务增强)**************** -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 添加事务切面 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 事务属性定义 -->
<tx:attributes>
<tx:method name="*"
rollback-for="com.jw.main.exception.ServiceException"
propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<!-- ***********************************切点表达式******************************************* -->
<aop:pointcut id="bizMethods"
expression="execution(* com.jw.xzms.sys.biz.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
<!-- end --> <bean id="userService"
class="com.jw.xzms.sys.biz.UserServiceImpl">
<property name="commonDao" ref="commonDao" />
</bean>
<!-- 通用的DAO -->
<bean id="commonDao" class="com.jw.main.dao.CommonDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
<!-- action -->
<import resource="springSystemAction.xml" />
为什么我的业务层根本就没有被spring代理呢,,所以更谈不上事务管理了。。
我的业务层是com.jw.xzms.sys.biz包下面的类的所有方法。。
<aop:pointcut id="bizMethods"
expression="execution(* com.jw.xzms.sys.biz.*.*(..))" />这里应该是对的噻。。我昏了。。郁闷了。。谁帮我一下。。 我在我的UserServiceImpl的login方法里面,
打出this.getClass().getName()看到不是被代理的, 。。 那么应该是我的配置文件写错了,就是上面的那写xml,但是我实在找不出来,,我想应该不会是缺少什么包。。高手指点, 高手指点啊,,指点,指点
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>//拦截
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="isLogin*">
PROPAGATION_REQUIRED,readOnly
</prop>
</props>
</property>
</bean>
//自动代理
<bean id="proxyUserService"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>userService</value>
</list>
</property>
<property name="interceptorNames"
value="transactionInterceptor" />
</bean>
http://www.blogjava.net/freeman1984/archive/2007/12/07/166112.html
希望对你有帮助...
<bean id="userService"
class="com.jw.xzms.sys.biz.UserServiceImpl">
<property name="commonDao" ref="commonDao" />
</bean>定义了可是没有被代理呢?
<aop:pointcut id="bizMethods"
expression="execution(* com.jw.xzms.sys.biz.*.*(..))" />这里已经代理了