跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[分享创造] JTracker IDEA 中最好的 MyBatis 日志格式化插件

发表于

前言

如果你使用 MyBatis ORM 框架,那么你应该用过 MyBatis Log 格式化插件,它可以让我们的程序输出的日志更人性化。

但是有一个问题,通常我们只能看到格式化后的效果,没办法知道这个 SQL 是谁执行的以及调用的链路。

如下图所示:

MyBatis Log Free|690x416, 75%

那么有没有办法知道调用链路和是谁执行的呢?办法也是有的,那就是本主题的主角 JTracker

什么是 JTracker

JTracker 是一个 Java 代码跟踪工具。目前它仅支持 MyBatis 日志跟踪,后续会支持 JPA 和 JDBC 所有的日志。也就是说,只要你的代码是基于 JDBC 操作的数据库,那么就可以显示并且格式化出来。

先来看看效果:

image|690x498, 75%

image|683x500, 75%

image|637x500, 75%

可以看到,输出日志的时候会把执行的 Mapper 给显示出来,当你点击一下会自动跳转到 Mapper 类的方法。

当我们按住“Ctrl + 鼠标左键”( macOS 是:⌘)可以打开执行 SQL 的调用链路,你可以同时固定多个面板,方便查找问题。

目前,JTracker 并非完全免费。其中,点击类名跳转到指定位置只有订阅用户才能使用。

如何安装?

https://plugins.jetbrains.com/plugin/24694

它仅支持 IDEA 2022.3 及以上版本安装。

后记

后续会支持更多功能,例如:JPA 、JDBC 的日志、SQL 执行耗时、链路各个阶段执行的耗时。当然也不仅限于 JDBC ,会支持更多有利于开发的功能。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.