今天遇见了一个奇怪的问题,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