代码:spring-dao.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<!-- 配置数据源(j2se和j2ee中均可使用) -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- 注入连接数据库的四个参数 -->
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
  <value>jdbc:mysql://localhost:3306/kyx?characterEncoding=utf8</value>
<!-- <value>jdbc:mysql://mysql.zfw.cc:3306/wwwjob?characterEncoding=utf8&autoReconnect=true</value> -->
</property>
<property name="username">
<value>root</value>
<!-- <value>dbcnwwwjob</value> -->
</property>
<property name="password">
<value>root</value>
<!-- <value>cdj6V4mvAtnJJMdh</value> -->
</property>
<property name="maxActive">
             <value>255</value>
         </property>
         <property name="maxIdle">
            <value>30</value>
         </property>
         <property name="maxWait">
            <value>10000</value>
         </property>
</bean>

<!-- 配置HibernateTemplate -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">   
        <property name="dataSource"><ref bean="dataSource"/></property>   
    </bean> 
<!-- 配置dao层的接口实现类 -->
<bean id="userDao"
class="com.kyx.dao.UserDaoImpl">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate"/>
</property>
</bean>
</beans>spring-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
<beans>
<!-- 配置service层 -->

<!-- 声明型事务的配置(包括配置事务管理器和事务拦截器) -->
<!-- 配置事务拦截器 -->
<bean id="transactionManager"  
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
        <property name="dataSource" ref="dataSource"></property>   
   </bean>   
<!-- 配置事务拦截器 -->
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 注入事务管理器 -->
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<!-- 配置事务属性 -->
<property name="transactionAttributes">
<props>
<prop key="*">
<!-- 用,追加异常 如:-AccountException,..,... -->
PROPAGATION_REQUIRED,-UserException
</prop>
</props>
</property>
</bean>

<!-- 配置service层借口实现类 -->
<bean id="userTarget" class="com.kyx.service.UserServiceImpl">
<property name="userDao">
<ref bean="userDao"/>
</property>
</bean>
<!-- 配置ProxyFactoryBean(工厂类),创建出代理对象(产品) -->
<bean id="userService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target">
<ref bean="userTarget" />
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
<!-- 注入代理器接口 -->
<property name="proxyInterfaces">
<list>
<value>com.kyx.service.IUserService</value>
</list>
</property>
</bean>
</beans>
dao文件
//修改cost 
@Transactional(rollbackFor=UserException.class)
public void updateCost(Charge charge)throws UserException{
jdbcTemplate.update("update cost set cost=cost+? where id=1", new Object[]{charge.getCost()});
System.out.println("更新了Cost...");
throw new UserException("有异常了...");
}运行此方法抛异常没有回滚?高手解答