断开MySQL服务器的命令是_mysql的配置文件有哪些

断开MySQL服务器的命令是_mysql的配置文件有哪些1、org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘…

	在与mysql的配置当中一定要注意的一点是设置serverTimezone=UTC[数据库教程]

1、org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘helloController‘: Unsatisfied dependency expressed through field ‘connection‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘getConnection‘ defined in class path resource [cn/chinaunicom/Config/BeanConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.sql.Connection]: Factory method ‘getConnection‘ threw exception; nested exception is 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.

 

2、Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘getConnection‘ defined in class path resource [cn/chinaunicom/Config/BeanConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.sql.Connection]: Factory method ‘getConnection‘ threw exception; nested exception is 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.

 

这些报错都是来自同一个错误就是设置serverTimezone=UTC。把这个设置好了就好了。

但是我有一点不清楚:

我明明在.yml文件里写了这个配置,但是就读不出来,就必须在当时用的时候协商写好:

    @Bean
    public Connection getConnection() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/text?serverTimezone=UTC", "root", "chen792979650");
        return connection;
    }
}

技术图片

 

我配置文件里面的东西

server:
  port: 9090
  #配置内嵌服务器的端口
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    #数据库url
    url: jdbc:mysql://localhost:3306/text?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    # 数据库访问账户
    username: root

明明我配置了的,并且访问的时候也是用的9090端口,说明这个配置文件是生效的。但是为什么不行?

 

 

 我猜测的原因:应该因为先后顺序的原因,在我debug的时候直接先对上面的连接数据库i的语句执行,再执行配置文件,但是再我先再连接数据库操作的时候已经出了问题,直接就报错了。 

在与mysql的配置当中一定要注意的一点是设置serverTimezone=UTC

原文地址:https://www.cnblogs.com/chenjiaolong/p/13470895.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/6787.html

(0)
上一篇 2023-04-03 19:00
下一篇 2023-04-03

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注