简体   繁体   中英

“No suitable driver” error occurs in Springboot 2.4.3 but not 2.2.2 RELEASE

I always got the "No suitable driver" error when I tried to connect to MySql (8.0.23) database. I specify the JDBC driver in application.yml file in my Springboot (2.4.3) application: https://github.com/aliensnoopy/crm/blob/6cd02d8042cf3aac275e39d642aec8dcaa9c85fb/src/main/resources/application.yml#L12

I can verify that my local MySql server is up and running and my password is correct since I can connect to the database from terminal.

However, after I change the springboot version from 2.4.3 to 2.2.2 RELEASE , everything magically works, There must be some subtle differences between these two Springboot versions that make this happen. but I can't figure out yet.

I setup some breakpoints to try to debug why it doesn't work in SpringBoot 2.4.3, I find that when the server starts, the user and password cannot be read correct and thus they are both null as the screenshot shows: 在此处输入图像描述

And the jdbcUrl is also null : 在此处输入图像描述

So, I guess the datasource information I specified in application.yml may not be read correctly in SpringBoot 2.4.3 . Is there any difference between SpringBoot 2.4.3 and SpringBoot 2.2.2 RELEASE in reading application.yml file or initializing the database connection?

Have you added the MySQL connector as a dependency to you boot maven or gradel file?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM