<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## 簡介 * 樂觀鎖采用mybatis-plus自帶,具體請看:https://mybatis.plus/guide/interceptor-optimistic-locker.html ## 如何啟用 * 框架默認沒有開啟樂觀鎖,若需要使用請根據如下步驟操作 * 以springboot版本為例,找到config類,加入如下代碼便可生效 ~~~ /** * mybatis-plus 攔截器集合 */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor(ObjectProvider<QueryInterceptor[]> queryInterceptors, TenantLineInnerInterceptor tenantLineInnerInterceptor, MybatisPlusProperties mybatisPlusProperties) { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // 配置租戶攔截器 interceptor.addInnerInterceptor(tenantLineInnerInterceptor); // 配置分頁攔截器 BladePaginationInterceptor paginationInterceptor = new BladePaginationInterceptor(); // 配置自定義查詢攔截器 QueryInterceptor[] queryInterceptorArray = queryInterceptors.getIfAvailable(); if (ObjectUtil.isNotEmpty(queryInterceptorArray)) { AnnotationAwareOrderComparator.sort(queryInterceptorArray); paginationInterceptor.setQueryInterceptors(queryInterceptorArray); } paginationInterceptor.setMaxLimit(mybatisPlusProperties.getPageLimit()); paginationInterceptor.setOverflow(mybatisPlusProperties.getOverflow()); // 配置分頁攔截器 interceptor.addInnerInterceptor(paginationInterceptor); // 配置樂觀鎖攔截器 interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); return interceptor; } ~~~ ![](https://img.kancloud.cn/22/4f/224f608d97db8dab5ccb40db63508e20_2856x1342.png) ## 如何配置 * 后端與數據庫配置version字段,并且為int類型 ![](https://img.kancloud.cn/81/de/81de05b84ee34d27576af407bcfaac2f_2050x1606.png) ![](https://img.kancloud.cn/c8/c5/c8c5bc51483344850ab6d6c439b3d7a6_1860x1510.png) * 前端配置version字段 ![](https://img.kancloud.cn/3d/64/3d64aad686a3ca010ca281d715a6bb3b_1220x888.png) ## 啟動測試 * 前后端啟動后,我們可以看到每次保存,version的值都會變動 ![](https://img.kancloud.cn/39/35/3935cf13fa4cb7fb75d821284d1c74e1_2610x880.png) * 這時候我們瀏覽器打開兩個編輯界面,模擬多人操作,當一個操作成功version變成6之后再保存另一個(打開時version為5),可以看到操作失敗,這樣一來,樂觀鎖配置便成功了 ![](https://img.kancloud.cn/c2/f5/c2f5581537e12448c7c73e66ac0e9c5d_2152x1760.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看