SpringBoot關於Msql報時區錯誤

SpringBoot運行報錯

  1. 控制檯錯誤信息
    只簡單展示錯誤信息:

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.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]

  1. 修改後的Url:
spring:
  profiles:
    active:
    - thymeleaf
    - mybatis
  # druid
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    # 注意mysql時區默認爲UTC  
    # 原來的url: jdbc:mysql://127.0.0.1:3306/xxx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
    url: jdbc:mysql://127.0.0.1:3306/xxx?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
    # driver-class-name: com.mysql.jdbc.Driver
    platform: mysql

3.運行完成:

2019-03-08 10:16:05.812  INFO 15660 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-08 10:16:06.046  INFO 15660 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2019-03-08 10:16:06.055  INFO 15660 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2019-03-08 10:16:06.080  INFO 15660 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2019-03-08 10:16:06.169  WARN 15660 --- [           main] s.d.s.w.r.p.ParameterDataTypeReader      : Trying to infer dataType org.springframework.ui.ModelMap
2019-03-08 10:16:06.212  INFO 15660 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: toLoginUsingGET_1
2019-03-08 10:16:06.256  INFO 15660 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [192.168.137.176:5672]
2019-03-08 10:16:06.276  INFO 15660 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Created new connection: rabbitConnectionFactory#38f77cd9:0/SimpleConnection@2afdf6b7 [delegate=amqp://guest@192.168.137.176:5672/, localPort= 8329]
2019-03-08 10:16:06.340  INFO 15660 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-03-08 10:16:06.343  INFO 15660 --- [           main] com.example.Miaosha1Application          : Started Miaosha1Application in 3.268 seconds (JVM running for 3.854)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章