spring boot 2.2.0 连接外部mysql时遇到的一些坑

场景:

spring boot 2.2.0,连接外部mysql(ip非127.0.0.1)

问题1:

spring boot报错:Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

解决方法:在application.properties中加入

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

问题2:

报错:Host is not allowed to connect to this MySQL server

解决方法:mysql开启远程连接

问题3:

报错:Caused by: org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution

原因:由于项目中使用了spring data jpa,所以要求mysql user 要有DDL权限

解决方法:在mysql中为user grant DDL权限

 

以上这几个问题,在本地mysql root下使用spring boot是并不会发生的

扫描二维码关注公众号,回复: 8641757 查看本文章

问题4:

warn: Establishing SSL connection without server's identity verification is not recommend

原因:MySQL在高版本需要指明是否进行SSL连接

解决方法:在mysql连接字符串url中加入ssl=true或者false即可

如:

spring.datasource.url=jdbc:mysql://10.100.xxx.xx:3306/xxx?characterEncoding=utf8&useSSL=true

问题5:

Log warning: Thread starvation or clock leap detected (housekeeper delta=springHikariConnectionPool)

spring boot 2.2.0 jdbc连接池使用了hikaricp,

其会做一个housekeeping检测 时钟跳变clock leap检测

参考:Log warning: Thread starvation or clock leap detected (housekeeper delta=springHikariConnectionPool)

当你进行debug调试的时候,可能会发生这个错误,是可以理解的

发布了442 篇原创文章 · 获赞 222 · 访问量 115万+

猜你喜欢

转载自blog.csdn.net/u013905744/article/details/102722157