今天在写Springboot项目时,连接MySql时出现个错误,控制台输出: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.
![4f64b909a03029acded3f7639021ffb3.png](https://i-blog.csdnimg.cn/blog_migrate/ff218922f685bade1548e4bd581e3572.jpeg)
是因为application-local.yml里面的写法有问题,所以报个了时区的问题。下图就是错误写法。
![d0b05990fdfd8ea9524597fcab50c5c5.png](https://i-blog.csdnimg.cn/blog_migrate/60967bf24081c0232d9ab0c2faf427c0.jpeg)
在连接字符串后面加上?serverTimezone=UTC,其中UTC是统一标准世界时间。
![5339023d195a533aad46825ab1b221c4.png](https://i-blog.csdnimg.cn/blog_migrate/45a26683ce225972e55f99c812a22974.jpeg)
连接字符串示例:jdbc:mysql://127.0.0.1:3306/bdproject?serverTimezone=UTC,为了避免中午乱码的问题,通常还会再后面加上&useUnicode=true&characterEncoding=UTF-8。最终的url写法就是jdbc:mysql://127.0.0.1:3306/bdproject?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8。这个字符串拼接的时候注意连接符号。
日常bug输出,每个bug都会出其不意,有时不经意间就制造了一个。
![7d9023b87e230c8ccccb8b8b79de37cb.png](https://i-blog.csdnimg.cn/blog_migrate/41fafff914e35b0d9096f525cf074f85.jpeg)