mysql - 为什么 Spring Batch 在我的 Ubuntu 20.04 机器上的 MySql 上创建小写表?
问题描述
我正在开发一个 Spring Batch 项目(在 Spring Boot 上运行),我遇到了一个棘手的问题。
基本上直到现在我都使用 H2 数据库。为了投入生产(在 Ubuntu 20.04 机器上),我试图用 MySql 替换它。
这是我的application.properties初始配置(使用 H2 数据库):
#Database Configuration
spring.datasource.url=jdbc:h2:mem:springbatch;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
因此,我使用 MySql 而不是 H2 将这些配置替换为这些新配置:
spring.datasource.platform=mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/spring
spring.datasource.username=andrea
spring.datasource.password=Aprile_12_Test
spring.datasource.initialization-mode=always
如您所见,初始化模式设置为始终运行我的 Spring Batch 应用程序,表将被创建到我的spring MySql 数据库中。表已创建但它们是小写的(进入使用的schema-mysql.sql文件都是大写的:
mysql> show tables;
+------------------------------+
| Tables_in_spring |
+------------------------------+
| BATCH_JOB_EXECUTION |
| BATCH_JOB_INSTANCE |
| DATABASECHANGELOG |
| DATABASECHANGELOGLOCK |
| batch_job_execution |
| batch_job_execution_context |
| batch_job_execution_params |
| batch_job_instance |
| batch_step_execution |
| batch_step_execution_context |
+------------------------------+
这似乎是一些错误的原因,因为它不会使用带有大写引用的表创建其他表。
为什么我会面临这个问题?我能做些什么来解决这个问题?是否存在指定使用.sql 文件中定义的大写名称的方法?
解决方案
由我自己解决,允许 Spring Boot\Batch 第一次创建数据库表。进入application.properties ::
spring.datasource.initialization-mode=always
从 pom.xml 中删除 Liquidebase 库:
<!--
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<scope>runtime</scope>
</dependency>
-->
最后在application.properties中禁用数据库表创建:
spring.datasource.initialization-mode=never
最后运行批处理。问题似乎是液基。
推荐阅读
- c - C:二维数组上的嵌套循环给出了意想不到的结果
- c - 为什么 open() 永远不会返回?
- python - 使用 Python3 和 Selenium 4 chrome 旋转用户代理
- python - 向 seaborn 箱线图添加自定义图例
- entity-framework - 删除表中的列表会引发 SQL 错误
- r - 将季度年份转换为R中季度的最后日期
- c# - 为什么在带有查找字段的创建请求中出现类型不匹配错误?
- javascript - 在 laravel Blade 的 foreach 循环中使用 javascript 函数
- html - 如何访问 HTML 中的根目录?(使用 / 不起作用)
- c# - 在环境变量 ASP.Net MVC 应用程序中正确存储数据库连接字符串