p6spy 非常典型 启用SQL日志「建议收藏」

大家好,又见面了,我是你们的朋友全栈君。

官网地址

gitHub地址

在项目的pom.xml中添加依赖

修改项目数据库连接地址Connection URL

jdbc:mysql://host/db 修改为 jdbc:p6spy:mysql://host/db

修改数据库 driver-class-name

driver-class-name: com.mysql.cj.jdbc.Driver 修改为 com.p6spy.engine.spy.P6SpyDriver

这边解释下第7项,因为p6spy会有配置文件,配置文件中需要您配置对应项目的driver-class-name

在classpath 下添加spy.properties配置文件,springboot项目会自动扫描

<code style="margin-left:0">#################################################################
# P6Spy Options File                                            #
# See documentation for detailed instructions                   #
# http://p6spy.github.io/p6spy/2.0/configandusage.html          #
#################################################################
#################################################################
# MODULES                                                       #
#                                                               #
# Module list adapts the modular functionality of P6Spy.        #
# Only modules listed are active.                               #
# (default is com.p6spy.engine.logging.P6LogFactory and         #
# com.p6spy.engine.spy.P6SpyFactory)                            #
# Please note that the core module (P6SpyFactory) can't be      #
# deactivated.                                                  #
# Unlike the other properties, activation of the changes on     #
# this one requires reload.                                     #
#################################################################
#modulelist=com.p6spy.engine.spy.P6SpyFactory,com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
################################################################
# CORE (P6SPY) PROPERTIES                                      #
################################################################
# A comma separated list of JDBC drivers to load and register.
# (default is empty)
#
# Note: This is normally only needed when using P6Spy in an
# application server environment with a JNDI data source or when
# using a JDBC driver that does not implement the JDBC 4.0 API
# (specifically automatic registration).
#driverlist=</code>

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/185543.html原文链接:https://javaforall.cn

未经允许不得转载:木盒主机 » p6spy 非常典型 启用SQL日志「建议收藏」

赞 (0)

相关推荐

    暂无内容!