p6spy可以将带参数的sql直接打出来方便调试。

1.gradle中引入

compile group: 'p6spy', name: 'p6spy', version: '3.8.1'

2.resources目录下增加spy.properties

module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=xxx.P6SpyLogger #自己实现的P6SpyLogger
# 使用日志系统记录sql
appender=com.p6spy.engine.spy.appender.Slf4JLogger
## 配置记录Log例外
excludecategories=info,debug,result,batc,resultset
# 设置使用p6spy driver来做代理
deregisterdrivers=true
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# 实际驱动
driverlist=oracle.jdbc.OracleDriver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 秒
outagedetectioninterval=

3.P6SpyLogger   

public class P6SpyLogger implements MessageFormattingStrategy {
@Override
public String formatMessage(int connectionId, String now, long elapsed,
String category, String prepared, String sql, String url) {
return !"".equals(sql.trim()) ? "| took "
+ elapsed + "ms | " + category + " | connection " + connectionId + "\n "
+ P6Util.singleLine(sql) + ";" : "";
}
}

4.DruidConfig

public DataSource druidDataSource() throws Exception {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName("oracle.jdbc.OracleDriver");
druidDataSource.setDbType("oracle");
.......
return new P6DataSource(druidDataSource);
}

springboot+Druid+oracle 配置p6spy的更多相关文章

  1. springboot+druid+mybatis-Plus 配置详解

    网上找了很多关于springboot+druid+mybatis-Plus的配置,遇见的很多问题 也没找到好的解决方案.折腾了好几天终于自己配置通过了. springboot的pom文件 <pa ...

  2. Springboot druid监控配置

    @Configuration public class DataSourceConfig { @Bean public ServletRegistrationBean statViewServlet( ...

  3. 使用springboot + druid + mybatisplus完成多数据源配置

    一. 简介 1. 版本 springboot版本为2.0.3.RELEASE,mybatisplus版本为2.1.9, druid版本为1.1.9,swagger版本为2.7.0 2. 项目地址   ...

  4. SpringBoot(七):集成DataSource 与 Druid监控配置

    绑定DataSource:Spring Boot默认的数据源是:org.apache.tomcat.jdbc.pool.DataSource,Druid是Java语言中最好的数据库连接池,并且能够提供 ...

  5. SpringBoot 使用yml配置 mybatis+pagehelper+druid+freemarker实例

    SpringBoot 使用yml配置 mybatis+pagehelper+druid+freemarker实例 这是一个简单的SpringBoot整合实例 这里是项目的结构目录 首先是pom.xml ...

  6. springboot+druid连接池及监控配置

    1. 问题描述 阿里巴巴的数据库连接池Druid在效率与稳定性都很高,被很多开发团队使用,并且自带的Druid监控也很好用,本章简单介绍下springboot+druid配置连接池及监控. 2. 解决 ...

  7. springboot整合Druid(德鲁伊)配置多数据源数据库连接池

    pom.xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-ja ...

  8. Springboot+Druid 动态数据源配置监控

    一.引入maven依赖,使用 starter 与原生 druid 依赖配置有所不同 <dependency> <groupId>com.alibaba</groupId& ...

  9. springboot+Druid+mybatis整合

    一.添加Druid.MySQL连接池.mybatis依赖 <!--整合Druid--> <dependency> <groupId>com.alibaba</ ...

随机推荐

  1. Java IO输入输出流 FileWriter 字符流

    字节缓冲流 //为什么要使用包装流,使用包装流是为了提高读写操作的性能. public class Packing_flowDemo { public static void main(String[ ...

  2. Android 画个电池出来(Paint和canvas)

    1.Android中很多时候都要自己去画一个自定义控件出来,就需要用到Paint和Canvas这两个类. 2.效果图:

  3. C# 真正完美的 汉字转拼音

    网上有很多说自己整理的汉字转拼音是完美的,但使用后才发现都是半吊的瓶子,问题多多. 常见的生僻字,或多音字识别,转换后简直让人感觉可怕. 主流的转换有三种:hash匹配,Npinyin,微软PinYi ...

  4. golang 重构博客统计服务

    欢迎关注楼主与他的小伙伴们的小站,每周分享一些技术文章,让我们在技术上一起成长------> 戳这里,欢迎光临小站 -_- 作为一个后端开发,在docker,etcd,k8s等新技术不断涌现的今 ...

  5. Persistent and Transient Data Structures in Clojure

    此文已由作者张佃鹏授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 最近在项目中用到了Transient数据结构,使用该数据结构对程序执行效率会有一定的提高.刚刚接触Trans ...

  6. ecliplse集成SVN

    按照下图操作 : SVN不同版本下载链接在文章底部有提供 上图点击add之后稍等一会就会弹出下图: 上图点击next之后: 最后等待完成之后重启ecliplse即可 重启ecliplse之后显示SVN ...

  7. kafka启动报错Cannot allocate memory;There is insufficient memory for the Java Runtime Environment to continue.

    kafka启动过程报错,配置没有问题,这就懵了!! Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000 ...

  8. xcode工程配置绝对路径与相对路径

    1.问题描述 一般我们在xcode里面配置包含工程目录下头文件的时候,都要关联着相对路径和绝对路径,如果只是自己用这个项目,用绝对路径的问题不大,但是如果你把工程发给别人,别人就要在改这个绝对路径,这 ...

  9. 墨菲定律与 IndexOutOfBoundsException(数组越界异常)

    今天维护又反馈了一问题过来,查询试卷时报数组越界异常: 2017-02-28 10:45:24,827[ERROR] HttpException[10.32.111.7:60446:2D07867BE ...

  10. asp手动给combox赋值

    ASPxComboBox cbSex = ASPxGridView1.FindEditFormTemplateControl("cmbUSER_SEX") as ASPxCombo ...