首页 > 数据库 >连接数据库 springboot环境下默认使用的是h2数据库,你没有对h2进行配置,这里我是mysql数据库,需要配置一下mysql数据库

连接数据库 springboot环境下默认使用的是h2数据库,你没有对h2进行配置,这里我是mysql数据库,需要配置一下mysql数据库

时间:2022-09-03 00:35:07浏览次数:67  
标签:jdbc springboot h2 数据库 配置 mysql

springboot环境下默认使用的是h2数据库,你没有对h2进行配置,这里我是mysql数据库,需要配置一下mysql数据库

Description:  Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:      
Property: driverclassname    
Value: com.mysql.cj.jdbc.Driver    
Origin: "driverClassName" from property source "source"     
Reason: Failed to load driver class 
  • 1
  • 2
  • 3
  • 4
  • 5

这个错误是因为springboot环境下默认使用的是h2数据库,你没有对h2进行配置,这里我是mysql数据库,需要配置一下

application.yml 
配置如下:
spring:
  application:
    name: item-service
  datasource:
    url: jdbc:mysql://localhost:3306/xxxx?serverTimezone=Asia/Shanghai 
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
application.properties
配置如下:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  • 1
  • 2
  • 3
  • 4
https://blog.csdn.net/qq_41887560/article/details/105411461

标签:jdbc,springboot,h2,数据库,配置,mysql
From: https://www.cnblogs.com/sunny3158/p/16651767.html

相关文章