spring 配置文件    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <!-- 事务拦截器bean需要依赖注入一个事务管理器 --> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <!-- 下面定义事务传播属性--> <props> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="finds*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="merge*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="*">PROPAGATION_REQUIRED,-Exception</prop> </props> </property> </bean> <!-- 定义BeanNameAutoProxyCreator--> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <!-- 指定对满足哪些bean name的bean自动生成业务代理 --> <property name="beanNames"> <value>*ServiceImpl</value> </property> <!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器--> <property name="interceptorNames"> <list> <!-- 此处可增加其他新的Interceptor --> <value>serviceInterceptor</value> <value>transactionInterceptor</value> <value>exceptionInterceptor</value> </list> </property> </bean>
但我 servicebean 是这么写的      <bean id="itemManagementService" class="net.carefx.cp.service.impl.ItemManagementServiceImpl">  </bean>我开始 是这样写的事务 不就应该没有被管理
但为什么我写测试的时候  
    public class ItemManagementServiceTest { private static ItemManagementService itemManagementService; @BeforeClass public static void setUpBeforeClass () throws Exception { ApplicationContext applicationContext = new ClassPathXmlApplicationContext ( "/net/carefx/cp/property/applicationContext.xml"); itemManagementService = (ItemManagementService) applicationContext.getBean ("itemManagementService"); } @Test public void testSaveItem(){ 。 } }
为什么 能提交到数据库 数据库 也能更新保存  但我配 在 web.xml
<listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/classes/net/carefx/cp/property/applicationContext.xml</param-value>
    </context-param>
然后 从页面上面调用  后台的  添删改 方法的时候
报错 说我事务 是 read-only 什么的