pom.xml

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId><!--sqlserver依赖 驱动jar-->
<scope>runtime</scope>
<version>6.4.0.jre8</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId><!--mybatis 依赖-->
<version>2.1.0</version>
</dependency>     <dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.17</version>
</dependency>

application.properties

#数据库连接
spring.datasource.druid.url=jdbc:sqlserver://localhost:;DatabaseName=localdemo
spring.datasource.druid.username=sa
spring.datasource.druid.password=
spring.datasource.druid.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
#*************************************** druid连接池配置 *********************************************
spring.datasource.druid.initial-size=
spring.datasource.druid.min-idle=
spring.datasource.druid.maxActive=
# 配置获取连接等待超时的时间(ms)
spring.datasource.druid.maxWait=
# 打开PSCache,并且指定每个连接上PSCache的大小
spring.datasource.druid.pool-prepared-statements=true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=
spring.datasource.druid.validation-query=SELECT
spring.datasource.druid.validation-query-timeout=
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
spring.datasource.druid.time-between-eviction-runs-millis=
# 配置一个连接在池中最小生存的时间,单位是毫秒
spring.datasource.druid.min-evictable-idle-time-millis=
##*******************监控配置 begin***************************###
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'stat'用于sql监控,'wall'用于防火墙,'log4j2'监控我本地的日志对于数据库的连接。其'#状态监控'配置参照stat或wall的,可以不设,实际中我就没设
spring.datasource.druid.filters=stat,wall,log4j2
#状态监控(SQL监控 配置StatFilter)
spring.datasource.druid.filter.stat.db-type=sqlserver
spring.datasource.druid.filter.stat.enabled=true
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.filter.stat.slow-sql-millis=
#状态监控(防火墙 配置WallFilter)
spring.datasource.druid.filter.wall.db-type=sqlserver
spring.datasource.druid.filter.wall.enabled=true
spring.datasource.druid.filter.wall.config.delete-allow=false
spring.datasource.druid.filter.wall.config.drop-table-allow=false
#监控过滤器(配置_配置WebStatFilter)
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
#druid监控页面
spring.datasource.druid.stat-view-servlet.enabled= true
spring.datasource.druid.stat-view-servlet.url-pattern= /druid/*
spring.datasource.druid.stat-view-servlet.reset-enable= false
spring.datasource.druid.stat-view-servlet.login-username= nsoft
spring.datasource.druid.stat-view-servlet.login-password= nsoft1122
#spring.datasource.druid.stat-view-servlet.allow= 127.0.0.1
##*******************监控配置 end*****************************###

然后登陆(我的本地端口8082,上下文根test):

http://localhost:8082/test/druid       (账户密码是自己设置的,nsoft  nsoft1122)

注: 网上很多关于springboot+druid,还需要配置一些java类。这都是旧版本的druid。新版本不需要配置java类。且,在我安照网上查找的配置application.properties后,监控页面等打开,但SQL监控项无数据,原因就是用新版本的druid,却用旧的方式配置导致的。

springboot+druid+mybatis的更多相关文章

  1. 2019-04-09 SpringBoot+Druid+MyBatis+Atomikos 的多数据源配置

    前面部分是网上找的,我按照网上写的把自己搭建的过程展示一次 1.引入依赖 目前项目本来使用到了Mybatis plus(在自己的Mapper接口中继承BaseMapper获得基本的CRUD,而不需要增 ...

  2. springboot+Druid+mybatis整合

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

  3. springboot+druid+mybatis plus的多数据源配置

    思路 yml中配置多个数据源信息 通过AOP切换不同数据源 配合mybatis plus使用 POM依赖 <dependency> <groupId>org.springfra ...

  4. SpringBoot系列七:SpringBoot 整合 MyBatis(配置 druid 数据源、配置 MyBatis、事务控制、druid 监控)

    1.概念:SpringBoot 整合 MyBatis 2.背景 SpringBoot 得到最终效果是一个简化到极致的 WEB 开发,但是只要牵扯到 WEB 开发,就绝对不可能缺少数据层操作,所有的开发 ...

  5. SpringBoot:Mybatis + Druid 数据访问

    西部开源-秦疆老师:基于SpringBoot 2.1.7 的博客教程 秦老师交流Q群号: 664386224 未授权禁止转载!编辑不易 , 转发请注明出处!防君子不防小人,共勉! 简介 对于数据访问层 ...

  6. SpringBoot整合MyBatis,HiKari、Druid连接池的使用

    SpringBoot整合MyBatis 1.创建项目时勾选mybatis.数据库驱动.   mysql驱动默认是8.x的版本,如果要使用5.x的版本,创建后到pom.xml中改. 也可以手动添加依赖 ...

  7. SpringBoot整合Mybatis之项目结构、数据源

    已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...

  8. Springboot与Mybatis整合

    最近自己用springboot和mybatis做了整合,记录一下: 1.先导入用到的jar包 <dependency> <groupId>org.springframework ...

  9. SpringBoot整合Mybatis【非注解版】

    接上文:SpringBoot整合Mybatis[注解版] 一.项目创建 新建一个工程 ​ 选择Spring Initializr,配置JDK版本 ​ 输入项目名 ​ 选择构建web项目所需的state ...

随机推荐

  1. 深入解读阿里云Redis开发规范

    Key命名设计:可读性.可管理性.简介性 规范建议使用冒号即:进行分割拼接,因为很多Redis客户端是根据冒号分类的.比如有几个Key:apps:app:1.apps:app:2和apps:app:3 ...

  2. linux默认的2.7升级到3.7版本

    CentOS7中自带的python版本是python-2.7.5,由于新开的虚拟机需要使用python3,于是便升级一下版本. 安装Python3.7.3 官网下载地址:https://www.pyt ...

  3. BladeX 部署centos启动顺序

    一:启动dockerservice docker start二:启动mysqldocker start mysql三:启动Harborsystemctl restart docker(如有修改daem ...

  4. url、href、src

    一.URL的概念 统一资源定位符(或称统一资源定位器/定位地址.URL地址等,英语:Uniform Resource Locator,常缩写为URL),有时也被俗称为网页地址(网址).如同在网络上的门 ...

  5. [LOJ3053]希望

    对于一组$s_{1\cdots k}$,合法的$u$构成一个连通块,满足$\left\lvert V\right\rvert-\left\lvert E\right\rvert=1$ 考虑算出算$f_ ...

  6. 解决angular+element原有组件样式不能覆盖element自带样式问题

    在对应的组件中写入 ::ng-deep   +     想要改变的element组件样式名即可

  7. 移动端1px边框解决方案

    在retina屏中,像素比为2(iPhone6/7/8)或3(iPhone6Plus/7Plus/8Plus),1px的边框看起来比真的1px更宽. 使用伪类加transform的方式 元素本身不定义 ...

  8. SpringBoot加载自定义yml文件

    自定义配置文件(跟SpringBoot的application.yml同一目录下): nlu-parse-rule: title: "NLU响应结果解析规则" desc: &quo ...

  9. 全球DEM高程数据下载

    本文主要介绍如何使用“迈高图-地图数据下载器”(以下简称:迈高图)下载全球DEM高程数据,任意下载范围自动拼接.裁剪.DEM高程数据支持下载导出为:GeoTIFF.XYZ.南方CASS等常用数据格式. ...

  10. TCP/IP详解 IP路由选择

    TCP/IP详解 IP路由选择 在本篇文章当中, 将通过例子来说明IP路由选择器过程 如图所示, 主机A与主机B分别是处在两个不同的子网当中, 中间通过一个路由连接. 如果主机A请求与主机B进行通行, ...