springboot结合mybatis-plus配置mysql数据库信息

MybatisPlus配置数据库信息

如果报错:
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:java.sql.SQLException: 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.
at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:49) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:594) ~[mybatis-plus-extension-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:422) ~[mybatis-plus-extension-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.getObject(MybatisSqlSessionFactoryBean.java:636) ~[mybatis-plus-extension-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:172) ~[mybatis-plus-boot-starter-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIB EnhancerBySpringCGLIBdedce697.CGLIB$sqlSessionFactory 2 ( < g e n e r a t e d > )   [ m y b a t i s − p l u s − b o o t − s t a r t e r − 3.1.0. j a r : 3.1.0 ] a t c o m . b a o m i d o u . m y b a t i s p l u s . a u t o c o n f i g u r e . M y b a t i s P l u s A u t o C o n f i g u r a t i o n 2(<generated>) ~[mybatis-plus-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration 2(<generated>) [mybatisplusbootstarter3.1.0.jar:3.1.0]atcom.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIB EnhancerBySpringCGLIB d e d c e 697 dedce697 dedce697 F a s t C l a s s B y S p r i n g C G L I B FastClassBySpringCGLIB FastClassBySpringCGLIB 7 c 6 b 6353. i n v o k e ( < g e n e r a t e d > )   [ m y b a t i s − p l u s − b o o t − s t a r t e r − 3.1.0. j a r : 3.1.0 ] a t o r g . s p r i n g f r a m e w o r k . c g l i b . p r o x y . M e t h o d P r o x y . i n v o k e S u p e r ( M e t h o d P r o x y . j a v a : 244 )   [ s p r i n g − c o r e − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s E n h a n c e r 7c6b6353.invoke(<generated>) ~[mybatis-plus-boot-starter-3.1.0.jar:3.1.0] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer 7c6b6353.invoke(<generated>) [mybatisplusbootstarter3.1.0.jar:3.1.0]atorg.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) [springcore5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIB EnhancerBySpringCGLIBdedce697.sqlSessionFactory() ~[mybatis-plus-boot-starter-3.1.0.jar:3.1.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
… 31 common frames omitted

就是表明数据源配置有问题,原配置

spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/stu_db
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver

正确的配置为

spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/stu_db?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值