springboot启动出现Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect‘ not set

博主遇到Spring Boot 2.0版本启动报错“Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set”的问题。尝试了百度到的加入配置、降低mysql-connector-java依赖版本等方案均无效。本地调试发现datasource注入为空,jdbcurl也为空,最后参考官方文档找到问题所在。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天遇见了一个奇怪的问题,springboot2.0版本启动报这个错

Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set。

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/es-learning
spring.datasource.username=root
spring.datasource.password=csucoderlee

# jpa config
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=validate

配置文件如上。

百度下,其他人的博客中,有如下解决方案:

1. 加入下面这行配置

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect 

2. mysql-connector-java依赖的版本降低到5.1.x的版本

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

3.  加入下面这行配置

spring.jpa.database=mysql

以上三种方案都试了不行。

自己本地debug了一下

 datasource注入的为空,执行了下datasource()的方法,发现注入的jdbcurl就是空的,但是配置里明明配置了url

后来看了下官方文档,原来springboot的高版本中url的配置要是这样才可以

spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/es-learning

评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值