启动日志MySQL SSL连接WARN日志解决方法在连接地址加上参数useSSL=false

本文针对MySQL连接时出现的WARN级别日志警告,提供了详细的解释及解决方案。建议在URL中加入useSSL=false参数来禁用SSL连接,以避免因未验证服务器身份而导致的安全风险。

控制台WARN日志:

Wed Oct 28 15:50:40 CST 2020 WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决方法:

在url地址加上参数:
localhost:3306/demo?useSSL=false

# ======================================================== # 公共配置:激活开发环境 # ======================================================== spring: profiles: active: dev # ======================================================== # 项目自定义配置 # ======================================================== ruoyi: name: RuoYi version: 4.8.1 copyrightYear: 2025 demoEnabled: true profile: D:/ruoyi/uploadPath/ # 文件上传根路径 addressEnabled: false # ======================================================== # 用户登录与密码策略配置(关键!修复 Bean 注入失败) # ======================================================== user: password: maxRetryCount: 5 # 密码错误最大重试次数 lockTime: 30 # 账号锁定时间(分钟) maxOnlineUsers: 20 # 最大在线用户数(用于踢出策略) # ======================================================== # 开发环境配置 (profile: dev) # ======================================================== --- spring: profiles: dev # ------------------------ # 数据源配置(Druid) # ------------------------ datasource: url: jdbc:mysql://localhost:3306/ry?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8 username: root password: ${MYSQL_PASSWORD:123456} driver-class-name: com.mysql.cj.jdbc.Driver # 显式声明驱动类更安全 druid: # --- 连接参数 --- initialSize: 5 minIdle: 5 maxActive: 20 maxWait: 60000 validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 # ============================= # 【✅ 关键修复】必须显式指定数据库类型 # ============================= db-type: mysql # 👈 Druid 不会自动推断此值,必须手动设置! # --- 监控页面 --- statViewServlet: enabled: true urlPattern: /druid/* loginUsername: admin loginPassword: ${DRUID_PASSWORD:admin123} allow: 127.0.0.1,192.168.1.100 deny: resetEnable: false # --- Web 统计过滤器 --- webStatFilter: enabled: true urlPattern: /* exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" # --- SQL 监控与防火墙 --- filter: stat: enabled: true logSlowSql: true slowSqlMillis: 1000 mergeSql: true wall: enabled: true # ============================= # 【✅ 再次强调】wall 模块也需要 db-type # ============================= db-type: mysql # 👈 防止 WallFilter 初始化时报 NPE config: dropTableAllow: false # 禁止执行 DROP TABLE # ------------------------ # Thymeleaf 模板引擎 # ------------------------ thymeleaf: mode: HTML encoding: utf-8 cache: false enabled: true suffix: .html prefix: classpath:/templates/ # ------------------------ # 国际化消息 # ------------------------ messages: basename: static/i18n/messages encoding: UTF-8 # ------------------------ # Jackson JSON 处理 # ------------------------ jackson: timeZone: GMT+8 dateFormat: yyyy-MM-dd HH:mm:ss defaultPropertyInclusion: NON_NULL # ------------------------ # 文件上传 # ------------------------ servlet: multipart: maxFileSize: 10MB maxRequestSize: 20MB # ------------------------ # DevTools # ------------------------ devtools: restart: enabled: true livereload: enabled: true # ------------------------ # 应用名称 # ------------------------ application: name: ruoyi-admin # ======================================================== # Server 配置 # ======================================================== server: port: 80 servlet: context-path: / tomcat: uri-encoding: UTF-8 accept-count: 1000 threads: max: 800 min-spare: 100 # ======================================================== # 日志配置(必须确保 logback-spring.xml 存在) # ======================================================== logging: level: com.ruoyi: info com.ruoyi.mapper: debug org.springframework: warn org.apache.ibatis: debug config: classpath:logback-spring.xml # ======================================================== # MyBatis 配置 # ======================================================== mybatis: typeAliasesPackage: com.ruoyi.**.domain mapperLocations: classpath*:mapper/**/*Mapper.xml configLocation: classpath:mybatis/mybatis-config.xml # ======================================================== # PageHelper 分页插件 # ======================================================== pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # ======================================================== # Shiro 安全框架 # ======================================================== shiro: user: loginUrl: /login unauthorizedUrl: /unauth indexUrl: /index captchaEnabled: true captchaType: math cookie: domain: path: / httpOnly: true maxAge: 30 cipherKey: session: expireTime: 30 dbSyncPeriod: 1 validationInterval: 10 maxSession: -1 kickoutAfter: false rememberMe: enabled: true # ======================================================== # XSS 防护 # ======================================================== xss: enabled: true excludes: /system/notice/* urlPatterns: /system/*,/monitor/*,/tool/* # ======================================================== # CSRF 防护 # ======================================================== csrf: enabled: false whites: /druid # ======================================================== # Swagger API 文档 # ======================================================== swagger: enabled: true 删掉那部分,完整展示修改后的代码
11-22
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值