Categories
mysql spring-boot

Spring Boot not running schema.sql

I am having an issue running the schema.sql upon running the program.

In my pom.xml, I already have the mysql config:

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

I only have one class

@SpringBootApplication
public class Application {...}

Under src/resources, I have schema.sql containing:

DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
...
);

Under src/resources, I have application.yml containing:

spring.datasource.driverClassName: "com.mysql.jdbc.Driver"
spring.datasource.url: "jdbc:mysql://localhost:3306/sample?useSSL=false"
spring.datasource.username: "****"
spring.datasource.password: "****"

I have confirmed that I am able to connect to the database “sample” upon starting the application, however, it’s not creating the table. Please advise.