概述
1、SpringBoot 整合Druid
参考文章:Druid(新版starter)在SpringBoot下的使用
2、报错解决
2.1、报错A
2.1.1、报错信息
The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
大体意思就是:
服务器时区值’�й������’无法识别或代表多个时区。 如果要使用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
2.1.2、解决方案
网上大部分的解决方案为在MySQL的URL后面加上?serverTimezone=UTC
但我添加上之后还是依旧报这个错误。
最终参考文章mysql时区问题设置才解决了这个问题。
即解决方案:
在可执行sql环境执行如下sql:
#全局设置时区为东8区,即北京时间
SET GLOBAL time_zone = '+8:00';
或
#仅修改当前会话时区
SET time_zone = '+8:00';
#立即生效修改
FLUSH PRIVILEGES;
2.2、报错B
2.2.1、报错信息
Error creating bean with name ‘dataSource’ defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]
Caused by: java.lang.IllegalAccessError: class com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper$$EnhancerBySpringCGLIB$$d6716674 cannot access its superclass com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper
2.2.2、报错原因
DruidDataSourceAutoConfigure会注入一个DataSourceWrapper,其会在原生的spring.datasource下找url,username,password等。而我们动态数据源的配置路径是变化的。
2.2.2、解决方案
启动类添加(exclude = DruidDataSourceAutoConfigure.class)即
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
最后
以上就是畅快火车为你收集整理的SpringBoot整合Druid报错解决:The server time zone value '�й���ʱ��' is unrecognized or represents.........1、SpringBoot 整合Druid2、报错解决的全部内容,希望文章能够帮你解决SpringBoot整合Druid报错解决:The server time zone value '�й���ʱ��' is unrecognized or represents.........1、SpringBoot 整合Druid2、报错解决所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复