【发布时间】:2018-08-26 10:04:00
【问题描述】:
我在运行程序时遇到了运行 schema.sql 的问题。
在我的 pom.xml 中,我已经有了 mysql 配置:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
我只有一门课
@SpringBootApplication
public class Application {...}
在 src/resources 下,我的 schema.sql 包含:
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
...
);
在 src/resources 下,我有 application.yml 包含:
spring.datasource.driverClassName: "com.mysql.jdbc.Driver"
spring.datasource.url: "jdbc:mysql://localhost:3306/sample?useSSL=false"
spring.datasource.username: "****"
spring.datasource.password: "****"
我已经确认我能够在启动应用程序时连接到数据库“示例”,但是,它并没有创建表。请指教。
【问题讨论】:
-
application.yml 还是 application.properties?
-
application.yml
-
但是您在上面放置的格式是属性文件。不是 yml 文件
-
yml 也可以有这种格式,而不仅仅是缩进的格式
标签: mysql spring-boot