有几种可能的原因:
- 你的实体类在与之相对的同一个子包中,或者在一个子包中,
@EnableAutoConfiguration
.如果没有,则你的spring应用不会看到它们,因此不会在db中创建任何内容 - 检查你的配置,似乎你正在使用某些hibernate特定选项,尝试将其替换为:
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialectspring.jpa.hibernate.ddl-auto=updatespring.datasource.driverClassName=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/testspring.datasource.username=testspring.datasource.password=
application.properties
必须在src/main/resources
文件夹中。
如果你没有正确指定方言,它可能会尝试默认与引导内存数据库捆绑在一起,并且(与我一样)我会看到它尝试连接到本地HSQL实例(请参阅控制台输出),并且无法更新模式。



