When developing Spring Boot JDBC applications, you might encounter the following error:
Environment
MySQL
Spring Boot 2.3
Reason
Spring Boot applications use HikariDataSource as the default connection pool. It expects the MySQL driver class name com.mysql.cj.jdbc.Driver, but this class is not found in the classpath.
Solution
Step 1: Add MySQL Dependency in Your build.gradle
Step 2: Specify the MySQL JDBC Driver Class Name in Your Spring Boot Application Properties
Add the following lines to your application.properties in the src/main/resources directory:
All the code is uploaded to GitHub. You can download the example code here.
Summary
This post walked through resolving the “Failed to bind properties” error in Spring Boot applications. The key steps involve ensuring the MySQL driver is correctly added to the project dependencies and specifying the driver class name in the application properties. By following these steps, you can avoid common configuration issues and ensure your application starts successfully.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem.
So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by
email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope: