<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 閱讀(3649) 評論(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 游客
    好文章啊.
    主站蜘蛛池模板: 亚洲综合久久夜AV | 国产三级免费观看| 久久青青草原亚洲AV无码麻豆 | 丁香亚洲综合五月天婷婷| 亚洲人成电影青青在线播放| 99久热只有精品视频免费观看17| 亚洲国产精品一区二区成人片国内 | 国产免费拔擦拔擦8X高清在线人| 亚洲精品无码久久久久AV麻豆| 粉色视频免费入口| 亚洲人成人网站在线观看| 国产V片在线播放免费无码 | 亚洲高清成人一区二区三区| 免费人成动漫在线播放r18| 久久激情亚洲精品无码?V| sihu国产精品永久免费| 亚洲AV成人一区二区三区AV| 99久久免费观看| 亚洲依依成人亚洲社区| 四虎永久在线免费观看| 精选影视免费在线 | 亚洲av色影在线| 三年片在线观看免费大全| 亚洲中文字幕AV每天更新| 四虎永久免费网站免费观看| 香蕉视频在线免费看| 亚洲男女一区二区三区| 免费看a级黄色片| 国产精品免费久久久久影院| 亚洲午夜久久影院| 女人被弄到高潮的免费视频| 黄色一级视频免费观看| 亚洲三级电影网址| 国产青草视频在线观看免费影院| 一级黄色片免费观看| 麻豆亚洲AV永久无码精品久久| 成人黄软件网18免费下载成人黄18免费视频 | 亚洲三级在线视频| 在线a亚洲v天堂网2018| 久久国产色AV免费观看| 国产精品亚洲精品日韩动图|