zoukankan      html  css  js  c++  java
  • springboot中数据库的连接

    mysql5.0

    1、#mysql数据库连接
    2、spring.datasource.driver-class-name=com.mysql.jdbc.Driver
     
    3、spring.datasource.url=jdbc:mysql://localhost:3306xxxx
     
    4、spring.datasource.username=root
     
    5、spring.datasource.password=123456
     
    mysql8.0
    1、spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
     
    2、spring.datasource.url=jdbc:mysql://localhost:3306/xxxx?serverTimezone=GMT%2B8
     
    3、spring.datasource.username=root
     
    4、spring.datasource.password=123456
     

    注意:

    1、这里的 url 使用了 ?serverTimezone=GMT%2B8 后缀,因为Spring Boot 2.1 集成了 8.0版本的jdbc驱动,这个版本的 jdbc 驱动需要添加这个后缀,否则运行测试用例报告如下错误:

    java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more 

    2、这里的 driver-class-name 使用了  com.mysql.cj.jdbc.Driver ,在 jdbc 8 中 建议使用这个驱动,之前的 com.mysql.jdbc.Driver 已经被废弃,否则运行测试用例的时候会有 WARN 信息

  • 相关阅读:
    fabric 网络操作中遇到的问题
    springBoot项目启动初始化数据
    行为验证码AJ-Captcha
    RestControllerAdvice注解无效问题
    记录美团一面问题
    关于springMVC
    作业08-集合
    选择排序
    Centos7 使用Minikube搭建Kubernetes集群
    Vscode 配置 Go语言插件
  • 原文地址:https://www.cnblogs.com/HezhenbinGoGo/p/13426391.html
Copyright © 2011-2022 走看看