隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 828795
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜

          一個關(guān)于struts + spring + hibernate整合事務配置的問題(請教高手)
          ... ...
          <?xml version="1.0" encoding="UTF-8"?>
          <beans
           xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

           <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
           </bean>
           
           <bean id="txProxyTemplate" abstract="true"
              class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager" ref="transactionManager"></property>
            <property name="transactionAttributes">
             <props>
              <prop key="create*">PROPAGATION_REQUIRED</prop>
              <prop key="update*">PROPAGATION_REQUIRED</prop>
              <prop key="delete*">PROPAGATION_REQUIRED</prop>
              <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
             </props>
            </property>
           </bean>
           
           <bean id="userDAO" class="dgut.ke.dao.impl.UserDAO">
                <property name="sessionFactory" ref="sessionFactory"></property>
           </bean>
          <bean id="userService"  parent="txProxyTemplate"  class="dgut.ke.service.impl.UserService">
              <property name="userDAO" ref="userDAO" />
          </bean>
          ... ....
          啟動Tomecat時出了錯.之前沒有添加事務處理時.上面的代碼是可以正常運行的.添加事務之后卻出現(xiàn)以下錯誤
          ERROR - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: Bean property 'transactionManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
          Caused by:
          org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManager' of bean class [dgut.ke.service.impl.UserService]: Bean property 'transactionManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
          解決辦法

          <bean id="userService"  parent="txProxyTemplate"  class="dgut.ke.service.impl.UserService">
              <property name="userDAO" ref="userDAO" />
          </bean>
          換成以下代碼就可以正常運行了
           <bean id="userService" parent="txProxyTemplate">
                <property name="target">
                     <bean class="dgut.ke.service.impl.UserService">
                          <property name="userDAO" ref="userDAO"></property>
                     </bean>
                </property>
           </bean>

          請教一下為什么會出現(xiàn)這種情況?
          哪位高手解釋下,謝謝!!!

          posted on 2007-10-07 13:36 Ke 閱讀(2792) 評論(1)  編輯  收藏 所屬分類: exception問題區(qū)

          FeedBack:
          # re: struts + spring + hibernate整合事務配置的問題(請教高手)[未登錄] 2007-11-30 09:03 hehe
          一樣的問題,在此找到答案,謝了
          曾試著這樣
          <bean id="userService" parent="txProxyTemplate">
          <property name="target">
          <bean class="dgut.ke.service.impl.UserService">
          </bean>
          </property>
          </bean>
          就是沒想到要把DAO作為屬性加進去
            回復  更多評論
            
          主站蜘蛛池模板: 遂昌县| 桂平市| 皮山县| 石泉县| 明星| 同仁县| 杨浦区| 大邑县| 琼中| 仙桃市| 黔南| 法库县| 岑溪市| 镇原县| 琼中| 柏乡县| 苏尼特右旗| 西畴县| 合阳县| 江达县| 日土县| 宁远县| 周口市| 大田县| 二连浩特市| 呼伦贝尔市| 枣强县| 南华县| 清远市| 新巴尔虎右旗| 遂溪县| 辽宁省| 云阳县| 即墨市| 满洲里市| 巴塘县| 常州市| 临朐县| 延长县| 交城县| 周宁县|