简体   繁体   English

表不存在 - SpringBoot Flyway MySql

[英]Table does not exist - SpringBoot Flyway MySql

I have a springboot application with H2 and have tried out some simple api(s) that does CRUD.我有一个带有 H2 的 springboot 应用程序,并尝试了一些执行 CRUD 的简单 api。 Now I am trying to move the db to MySQL running in a docker instance.现在我正在尝试将数据库移动到在 docker 实例中运行的 MySQL。

I have flyway configured with init script under /resources/db.migration package.我在 /resources/db.migration 包下使用初始化脚本配置了 flyway。 I am able to connect to database from my intellij.我可以从我的智能连接到数据库。 I am able to build and start the application.我能够构建并启动应用程序。

However, upon sending a REST request to save a resource, the app throws an exception.但是,在发送 REST 请求以保存资源时,应用会抛出异常。 And I see java.sql.SQLSyntaxErrorException: Table 'task-db.customer' doesn't exist in the application log.我看到java.sql.SQLSyntaxErrorException: Table 'task-db.customer' doesn't exist But after building the project, I could see the customer table created via Flyway.但是在构建项目之后,我可以看到通过 Flyway 创建的客户表。 So the table does exist before starting the application.因此该表在启动应用程序之前确实存在。

I tried rebuilding/invalidating cache and restarting intellij but did not help.The only fly configuration I have used is - flyway:locations: classpath:db/migration .我尝试重建/使缓存失效并重新启动 intellij 但没有帮助。我使用的唯一飞行配置是 - flyway:locations: classpath:db/migration Below is the DDL in the flyway init script.下面是 flyway 初始化脚本中的 DDL。

CREATE TABLE IF NOT EXISTS `CUSTOMER` (
`CUSTOMER_ID` int NOT NULL AUTO_INCREMENT,
`FIRST_NAME` varchar(45) DEFAULT NULL,
 PRIMARY KEY (`CUSTOMER_ID`)
);` 

How can I resolve it?我该如何解决? Where should I be looking at?我应该看哪里? Am I missing something?我错过了什么吗?

Updated the tables to lowercase in the flyway script and entities and that worked.将飞路脚本和实体中的表格更新为小写并且有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM