如何使用Spring Boot解决Mysql断连问题的详细介绍
技术百科
黄舟
发布时间:2017-03-21
浏览: 次 本篇文章主要介绍了spring boot如何解决mysql断连问题,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
在Spring Boot JPA连接Mysql的过程中,经过 8小时后会发现断连的情况。application.properties配置如下(此坑我跳过,欢迎入坑):
spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.Driver
原因分析:
mysql在默认的情况下,如果发现一个连接空闲时间超过8小时,将会在数据库端自动关闭这个连接。(mysql wait_timeout 为8小时)。
解决方式:
1 . Mysql 5 版本之前可以通过在URL后面加入autoReconnect=true,如:
spring.datasource.url=jdbc:mysql://localhost/test?autoReconnect=true
2 . application.properties文件中加入:
spring.datasource.test-on-borrow=false spring.datasource.test-while-idle=true spring.datasource.time-between-eviction-runs-millis= 3600000
3 . 粗暴点的直接修改 wait_timeout 时间:
show global variables like 'wait_timeout';
推荐第二种方式
# 会在
# 可以通过
# 给大家
# 小编
# 后会
# 也给
# 第二种
# 如何解决
# mysql
# 做个
# 看看吧
相关栏目:
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
AI推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
SEO优化<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
技术百科<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
谷歌推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
百度推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
网络营销<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
案例网站<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
精选文章<?muma echo $count; ?>
】
相关推荐
- 如何在Golang中实现服务熔断与限流_Golan
- Win10如何更改电脑休眠时间_Windows10
- 如何在 Go 中判断变量是否为函数类型
- Win11任务栏颜色怎么改_Win11自定义任务栏
- Win11怎么关闭粘滞键_彻底禁用Windows
- Win11此电脑不在桌面上_Windows 11桌
- Win11怎么关闭小组件_Win11禁用任务栏天气
- Win11怎么关闭右下角弹窗_Win11拦截系统通
- Mac如何使用听写功能_Mac语音输入打字【效率技
- 如何用::实现单例模式_php静态方法与作用域操作
- Win11怎么查看激活状态_查询Windows 1
- Win11如何设置ipv6 Win11开启IPv6
- php控制舵机角度怎么调_php发送pwm信号控制
- Python文件和流处理指南_高效读写大体积数据文
- 如何在Golang中处理二进制数据_Golang
- Win11怎么检查TPM2.0模块_Windows
- MAC怎么设置程序窗口永远最前_MAC窗口置顶插件
- 如何快速验证Golang安装是否成功_运行go v
- Win11怎么设置ip地址_Windows 11手
- c++如何使用std::bitset进行位图算法_
- c++输入输出流 c++ cin与cout格式化输
- VSC怎么创建PHP项目_从零开始搭建项目的步骤【
- Python脚本参数接收_sys与argparse
- mac本地php环境如何开启curl_curl扩展
- 如何更改Windows资源管理器的默认启动位置?(
- 如何在Golang中使用container/hea
- Win11怎么修复系统文件_使用sfc命令修复Wi
- 如何使用Golang构建简易投票统计功能_Gola
- Python音视频处理高级项目教程_FFmpegP
- Win10系统怎么查看显卡温度_Win10任务管理
- 如何使用Golang处理静态文件缓存_提高页面加载
- Win11触摸板没反应怎么办_开启Win11笔记本
- c++ namespace命名空间用法_c++避免
- 如何处理“XML格式不正确”错误 常见XML we
- Win11开始菜单打不开_修复Windows 11
- Win11资源管理器卡顿怎么办 Win11文件资源
- Win11怎么设置DNS服务器_Windows11
- Windows怎样拦截QQ浏览器广告_Window
- Windows10如何更改计算机工作组_Win10
- Windows10如何查看蓝屏日志_Win10使用
- Windows10如何彻底关闭自动更新_Win10
- Mac的“调度中心”与“空间”怎么用_Mac多桌面
- Win11任务栏怎么固定应用 Win11将软件图标
- 如何在Golang中理解指针比较_Golang地址
- Windows10系统怎么查看设备管理器_Win1
- VSC里PHP变量未定义报错怎么解决_错误抑制技巧
- MySQL 中使用 IF 和 CASE 实现查询字
- Go 中实现 Python urllib.quot
- Python类装饰器使用_元编程解析【教程】
- Windows蓝屏错误0x00000018怎么处理

QQ客服