<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 0, comments - 77, trackbacks - 0, articles - 356
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    spring中配置二級緩存

    Posted on 2007-08-16 14:12 semovy 閱讀(3656) 評論(4)  編輯  收藏 所屬分類: Hibernatespring

    1.首先,在spring的hibernate配置里(我的是applicationContext-hibernate.xml) 加上如下屬性:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">         
      <property name="dataSource">
       <ref bean="dataSource"/>
      </property>
      <property name="mappingResources">
       <list>
        <value>org/appfteaching/model/TArticleclass.hbm.xml</value>
       </list>
      </property>
      <property name="hibernateProperties">
       <props>
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
              <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
              <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
              <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
              <prop key="hibernate.cache.use_query_cache">true</prop>
              <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
       </props>   
      </property>  
     </bean> 

    2.其次,在src目錄下的ehcache.xml中配置如下信息(如果是默認ehcache.xml則會有<cache name="sampleCache1">和<cache name="sampleCache2>",去掉)

    <cache name="org.hibernate.cache.StandardQueryCache"
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="300"
            timeToLiveSeconds="4200"
            overflowToDisk="true"
            />

        <!-- Sample cache named sampleCache2
            This cache contains 1000 elements. Elements will always be held in memory.
            They are not expired. -->

        <cache name="org.hibernate.cache.UpdateTimestampsCache"
            maxElementsInMemory="5000"
            eternal="true"
            timeToIdleSeconds="0"
            timeToLiveSeconds="0"
            overflowToDisk="false"
            />

    3.將你要緩存的model加進ehcache.xml里

    <cache name="org.appfteaching.model.TArticleclass"
         maxElementsInMemory="1000"
            eternal="false"
            timeToIdleSeconds="100"
            timeToLiveSeconds="4200"
            overflowToDisk="true"
         />  

    4.最后一步,在TArticleclass.hbm.xml里加上

    <cache usage="read-write"/>

    啟動Tomcat,如發現如下錯誤

    Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
    Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.

    則是第二步沒有做,加上即可.配置完畢


    評論

    # re: spring中配置二級緩存   回復  更多評論   

    2008-11-04 17:02 by sss
    很好很好,學習了,有效

    # re: spring中配置二級緩存   回復  更多評論   

    2010-07-15 00:19 by 游客
    很好 博主很強大

    # re: spring中配置二級緩存   回復  更多評論   

    2011-12-18 20:33 by 游客
    好文章啊.
    主站蜘蛛池模板: 日本一道本不卡免费 | 亚洲国产日韩在线成人蜜芽 | 又黄又大的激情视频在线观看免费视频社区在线 | 日韩一卡2卡3卡4卡新区亚洲| 亚洲av无码一区二区三区人妖| 成年女人午夜毛片免费视频 | 波多野结衣久久高清免费| 天天爽亚洲中文字幕| 成人看的午夜免费毛片| 亚洲美国产亚洲AV| 好大好硬好爽免费视频| 国产亚洲美女精品久久久2020| 猫咪免费人成在线网站| 精品国产日韩亚洲一区| 成在人线av无码免费高潮水| 国产自偷亚洲精品页65页| 成在人线av无码免费高潮喷水| 妞干网免费视频在线观看| 在线综合亚洲欧洲综合网站| 在线免费观看污网站| 污视频网站免费在线观看| 国产精品亚洲mnbav网站| 99在线免费视频| 91精品国产亚洲爽啪在线影院| 曰批视频免费30分钟成人| 亚洲精品成a人在线观看☆| 亚洲av高清在线观看一区二区| 中国一级特黄的片子免费| 精品亚洲aⅴ在线观看| 一级大黄美女免费播放| 免费观看大片毛片| 污污免费在线观看| 国产成人亚洲综合无码精品| 97在线视频免费| 中文字幕亚洲码在线| 亚洲午夜AV无码专区在线播放 | 亚洲中文无码mv| 亚洲综合伊人久久大杳蕉| 91精品成人免费国产片| 亚洲精品蜜夜内射| 国产亚洲精品岁国产微拍精品|