Could not create connection to database server. Attempted reconnect 3 times. Giving up.

在启动服务时,报出Could not create connection to database server. Attempted reconnect 3 times. Giving up.这个错误。报错图:

Could not create connection to database server. Attempted reconnect 3 times. Giving up._第1张图片

这是我的 application.yml 配置信息:


spring:
  application:
    name: softactivity
  http:
    encoding.charset: UTF-8
    encoding.force: true
  mvc:
    static-path-pattern: /**

  resources:
    static-locations: classpath:/templates/
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url:  jdbc:mysql://127.0.0.1:3306/works?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true&&allowMultiQueries=true&verifyServerCertificate=false
    username: root
    password: root
    
  jpa:
    database: MYSQL
    show-sql: true

查看多次,上网查询修改了多次,都还是报这个错误。
最终发现因 mysql-connector-java 中的jar版本太高,与自己的mysql版本不符,在这里插入代码片所导致的错误,将jar的版本调到6.0以下即可。本人最终将jar的版本换成了5.1.30,配置信息没有问题,错误解决。Could not create connection to database server. Attempted reconnect 3 times. Giving up._第2张图片
Could not create connection to database server. Attempted reconnect 3 times. Giving up._第3张图片

如果还未解决您的问题,请检查配置的正确性或其他:

  datasource:
    driver:xxxx
    url:  xxxx
    username: xxxx
    password: xxxx

你可能感兴趣的:(报错)