Spring Boot
September 9, 2021
M04 Q11 What properties do you have to define in order to configure external MySQL?
To configure external MySQL in Spring Boot you need to specify URL, Username and Password for Data Source by defining following properties:
Optionally, you can also explicitly specify JDBC Driver:
To initialize Database during application startup via data.sql and schema.sql you also need to specify property:
You also need to specify connector dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>You will also need a way to access database, simplest approach is to use JDBC:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>