mybatis日志还原SQL

介绍网站

sql.xia-fei.com
把mybatis 输出的sql日志还原成完整的sql语句

背景

平时开发过成过程中吧。需要调式mybatis运行的SQL
通长我们会这么做吧

1.首先我们会查看mybatis的log日志
2.将日志里面的? 手动替换成参数

LOG文本还原SQL

于是我开发了一个网站将Mybatis log内容还原成sql
例如日志内容

2018-07-20 17:32:00.544 superapiplus:WYKlypR6JN1tZndzTMI0yAde416673 DEBUG batchInsert -
                ==>  Preparing: insert into sh_push_code (id, user_id, open_id, form_id, form_id_status, generate_time, create_time, update_time, create_person, update_person) values (?, ?, ?, ?, ?, ?, now(), now(), 'system', 'system') 
2018-07-20 17:32:00.544 superapiplus:WYKlypR6JN1tZndzTMI0yAde416673 DEBUG batchInsert -
                ==> Parameters: null, 122527041(Long), ouMUI0fPepwDr7YFVvtbONMi_nRk(String), 1532079119360(String), 1(Integer), 2018-07-20 17:32:00.543(Timestamp)
2018-07-20 17:32:00.545 superapiplus:WYKlypR6JN1tZndzTMI0yAde416673 DEBUG batchInsert -
                <==    Updates: 1
2018-07-20 17:32:00.723 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG selectRolesByStoreId -
                ==>  Preparing: select id, store_id, role_code, app_template_id, create_person, create_time, update_person, update_time from sh_role_store where store_id = ? 
2018-07-20 17:32:00.724 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG selectRolesByStoreId -
                ==> Parameters: 1617818(Integer)
2018-07-20 17:32:00.724 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG selectRolesByStoreId -
                <==      Total: 17
2018-07-20 17:32:00.725 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG queryByUserIds -
                ==>  Preparing: select id, member_id, role_id, star_level, store_id, is_enable, begin_time, end_time, create_person, (select min(d.create_time) from sh_employee_info_detail d WHERE del = 0 and d.member_id = k.member_id) as create_time, update_person, update_time from sh_employee_info_detail k where del = 0 and ? >=begin_time and end_time > ? and member_id in ( ? , ? , ? , ? , ? , ? , ? , ? , ? ) and store_id = ? 
2018-07-20 17:32:00.725 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG queryByUserIds -
                ==> Parameters: 2018-07-20 17:32:00.725(Timestamp), 2018-07-20 17:32:00.725(Timestamp), 122207147(Integer), 122060800(Integer), 122053199(Integer), 122038827(Integer), 120143921(Integer), 121993631(Integer), 120139730(Integer), 120141267(Integer), 120141259(Integer), 1617818(Integer)
2018-07-20 17:32:00.727 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG queryByUserIds -
                <==      Total: 9
2018-07-20 17:32:00.727 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG selectHaveEmployeeRole -
                ==>  Preparing: select l.*, (select count(*) from sh_employee_info_detail k where k.role_id = s.id and ? >= k.begin_time and k.end_time > ?) as count, s.id as role_id from sh_role_list l join sh_role_store s on l.role_code = s.role_code join sh_employee_info_detail d on d.role_id = s.id where s.store_id = ? and d.del = 0 and ((? >= d.begin_time and d.end_time > ?) or ((? >= d.begin_time and d.end_time > ?)) ) GROUP BY l.role_code order by sort_by 
2018-07-20 17:32:00.728 sh:6IQwHsHvIHcrOvL3inZFNQde72201 DEBUG selectHaveEmployeeRole -
                ==> Parameters: 2018-07-01 00:00:00.0(Timestamp), 2018-07-01 00:00:00.0(Timestamp), 1617818(Integer), 2018-07-01 00:00:00.0(Timestamp), 2018-07-01 00:00:00.0(Timestamp), 2018-08-01 00:00:00.0(Timestamp), 2018-08-01 00:00:00.0(Timestamp)

我们可以随意复制一部分日志内容,粘贴到sql.xia-fei.com
它就会将日志内容转换成可运行的SQL

页面结果如图


image

各位开发大神,有啥优化改善建议,欢迎在下方留言-,-

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 关于Mongodb的全面总结 MongoDB的内部构造《MongoDB The Definitive Guide》...
    中v中阅读 32,070评论 2 89
  • 我一直不相信这世间有妖,直到闯入了那栋老屋。 “砰砰砰!” “谁呀!”睡眼惺忪的我不情愿地跑去开了门,没想到竟是我...
    葫芦世界平台阅读 656评论 0 0
  • 1 这是一家铺面很小的打印店,位于学校的中心地段,其实我不是很喜欢来这家打印店,可是因为离教室近赶时间的时候就不得...
    希希兮兮阅读 368评论 0 2
  • 前言 当我写下这个题目之后,我想到了一首歌词"长大以后,我只能奔跑,我多害怕 黑暗中跌倒 ",我不由得哼起这首歌,...
    AI云栈阅读 185评论 0 0
  • 时下热播剧《欢乐颂》,吸引观众的是对现实的真实反映。几个人就像出现在我们身边,安迪的干练学识,樊胜美的虚荣精明,小...
    东东西西2016阅读 212评论 0 1