Spring Boot DataSource Autoconfiguration
Jump to navigation
Jump to search
Internal
Overview
DataSource beans can be explicitly configured, but that is usually unnecessary. It is simpler to use Spring Boot autoconfiguration facilities and just provide the URL for the database and credentials.
Configuration
spring:
datasource:
url: jdbc:mysql://localhost/mydatabase
username: someuser
password: somepasswd
This implies that the appropriate driver is added to the build. If that is done, it is usually unnecessary to specify the JDBC driver class. Spring Boot can figure it out from the structure of the database URL.
If there is a problem, it can be set with:
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver