springboot+druid+mybatis
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的更多相关文章
- 2019-04-09 SpringBoot+Druid+MyBatis+Atomikos 的多数据源配置
前面部分是网上找的,我按照网上写的把自己搭建的过程展示一次 1.引入依赖 目前项目本来使用到了Mybatis plus(在自己的Mapper接口中继承BaseMapper获得基本的CRUD,而不需要增 ...
- springboot+Druid+mybatis整合
一.添加Druid.MySQL连接池.mybatis依赖 <!--整合Druid--> <dependency> <groupId>com.alibaba</ ...
- springboot+druid+mybatis plus的多数据源配置
思路 yml中配置多个数据源信息 通过AOP切换不同数据源 配合mybatis plus使用 POM依赖 <dependency> <groupId>org.springfra ...
- SpringBoot系列七:SpringBoot 整合 MyBatis(配置 druid 数据源、配置 MyBatis、事务控制、druid 监控)
1.概念:SpringBoot 整合 MyBatis 2.背景 SpringBoot 得到最终效果是一个简化到极致的 WEB 开发,但是只要牵扯到 WEB 开发,就绝对不可能缺少数据层操作,所有的开发 ...
- SpringBoot:Mybatis + Druid 数据访问
西部开源-秦疆老师:基于SpringBoot 2.1.7 的博客教程 秦老师交流Q群号: 664386224 未授权禁止转载!编辑不易 , 转发请注明出处!防君子不防小人,共勉! 简介 对于数据访问层 ...
- SpringBoot整合MyBatis,HiKari、Druid连接池的使用
SpringBoot整合MyBatis 1.创建项目时勾选mybatis.数据库驱动. mysql驱动默认是8.x的版本,如果要使用5.x的版本,创建后到pom.xml中改. 也可以手动添加依赖 ...
- SpringBoot整合Mybatis之项目结构、数据源
已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...
- Springboot与Mybatis整合
最近自己用springboot和mybatis做了整合,记录一下: 1.先导入用到的jar包 <dependency> <groupId>org.springframework ...
- SpringBoot整合Mybatis【非注解版】
接上文:SpringBoot整合Mybatis[注解版] 一.项目创建 新建一个工程 选择Spring Initializr,配置JDK版本 输入项目名 选择构建web项目所需的state ...
随机推荐
- js---省略花括号{}的几种表达式
在进行js的书写中,对于常见的if,for,while是可以简写,省略花括号{}的: var a = 10,b = 20; /** * if 简写 */ if(a > b) console.lo ...
- laravel5.8ajax请求auth认证返回302的解决方法。
注册 /app/Http/Controller/Auth/RegisterController.php <?php namespace App\Http\Controllers\Auth; us ...
- MyCat不支持毫秒 bug fix
问题描述:mysql jdbc的驱动(mysql-connector-java-5.1.34.jar)设置的服务器的版本号最低是5.6.4才不会截取时间毫秒,但是现在取的是mycat 的版本号 5.5 ...
- &和&&的区别?
&运算符有两种用法:(1)按位与:(2)逻辑与.&&运算符是短路与运算.逻辑与跟短路与的差别是非常巨大的,虽然二者都要求运算符左右两端的布尔值都是true整个表达式的值才是tr ...
- UE4 Animation]IK Related
转自:https://dawnarc.com/2018/05/ue4animationik-related/ Examples 工程1 在油管上看到一个UE4 IK动画的demo工程示例 该示例作者的 ...
- Win10最详细的优化设置 完美解决磁盘100%占用
1.用360优化win10后开不了机的问题原因是禁用了三个服务:在360应用软件服务里dmwappushsvc.diagnsticsTrackingservice.coreMessaging这三个要开 ...
- Python学习之路:通过分片的方式修改列表的技巧(拓展知识)
一.为列表添加值 用分片的方式可以在列表的头部和尾部添加值 1.在列表的头部添加值 x = [1, 2, 3] #创建列表x x[:0] = [0] #用分片的方式在列表头部添加值 print(x) ...
- Python之路【第三十一篇】:django ajax
Ajax 文件夹为Ajaxdemo 向服务器发送请求的途径: 1.浏览器地址栏,默认get请求: 2.form表单: get请求 post请求 3.a标签,超链接(get请求) 4.Ajax请求 特点 ...
- flink checkpoint状态储存三种方式选择
Flink 提供了三种可用的状态后端:MemoryStateBackend,FsStateBackend,和RocksDBStateBackend. MemoryStateBackend Memory ...
- mysql测试,配置环境 mysql' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
参考链接:https://www.cnblogs.com/ios9/p/9713388.html 1.设置一下环境变量: 右击我的电脑——>属性——>高级系统设置——> ...