步骤
数据源
spring:
datasource:
username: root
password: Hello12345
url: jdbc:mysql://127.0.0.1:3306/demo
driver-class-name: com.mysql.cj.jdbc.Driver
schema:
- classpath:student.sql
initialization-mode: always
在resources文件下建立student.sql
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
注意
需要设置 initialization-mode: always7