MyBatisPlus插件扩展_PerformanceInterceptor性能分析插件的使用
生活随笔
收集整理的這篇文章主要介紹了
MyBatisPlus插件扩展_PerformanceInterceptor性能分析插件的使用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
場(chǎng)景
項(xiàng)目搭建專(zhuān)欄:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194
簡(jiǎn)介
性能分析攔截器,用于輸出每條 SQL 語(yǔ)句及其執(zhí)行時(shí)間
參數(shù):maxTime SQL 執(zhí)行最大時(shí)長(zhǎng),超過(guò)自動(dòng)停止運(yùn)行,有助于發(fā)現(xiàn)問(wèn)題。
參數(shù):format SQL SQL是否格式化,默認(rèn)false。
實(shí)現(xiàn)
來(lái)到項(xiàng)目下的applicationContext.xml中配置sqlSessionFactoryBean的地方。
<bean id="sqlSessionFactoryBean" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean"><!-- 數(shù)據(jù)源 --><property name="dataSource" ref="dataSource"></property><property name="configLocation" value="classpath:mybatis-config.xml"></property><!-- 別名處理 --><property name="typeAliasesPackage" value="com.badao.beans"></property>?<!-- 注入全局MP策略配置 --><property name="globalConfig" ref="globalConfiguration"></property>?<!-- 插件注冊(cè) --><property name="plugins"><list><!-- 注冊(cè)分頁(yè)插件 --><bean class="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></bean><!-- 注冊(cè)執(zhí)行分析插件 --><bean class="com.baomidou.mybatisplus.plugins.SqlExplainInterceptor"><property name="stopProceed" value="true" /></bean><!-- 注冊(cè)性能分析插件 --><bean class="com.baomidou.mybatisplus.plugins.PerformanceInterceptor"><!-- 單位為毫秒 --><property name="maxTime" value="100" /><!--SQL是否格式化 默認(rèn)false--><property name="format" value="true" /></bean></list></property>?</bean>編寫(xiě)測(cè)試方法
/**** 性能分析插件*/@Testpublic void testPaginationInterceptor() {Employee employee = new Employee();employee.setName("PaginationInterceptor測(cè)試2");employee.setAge(23);employeeMapper.insert(employee);}運(yùn)行測(cè)試方法
然后把時(shí)間改短點(diǎn)再重新測(cè)試
源碼下載
https://download.csdn.net/download/badao_liumang_qizhi/11147598
總結(jié)
以上是生活随笔為你收集整理的MyBatisPlus插件扩展_PerformanceInterceptor性能分析插件的使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MyBatisPlus插件扩展_SqlE
- 下一篇: MyBatisPlus插件扩展_Opti