7

基于 mysql 数据库的 spring 项目, sql 有 H2 不支持的语法,怎么高效搞连接数据库的...

 2 years ago
source link: https://www.v2ex.com/t/784898
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

基于 mysql 数据库的 spring 项目, sql 有 H2 不支持的语法,怎么高效搞连接数据库的功能测试?

  shadowfish0 · 8 小时 15 分钟前 · 311 次点击

为了兼容 H2 改 SQL 是肯定不可能的吧,项目本来就是准备移植过来的,老的 SQL 有些很长完全不敢改。弃用 H2,直接连远程数据库(因为要在阿里云流水线上跑测试,只能要不 H2 要不连远程数据库),又非常慢,咋办呢?

项目是用 mybatis 的,暂时想到的办法是能不能动态切换下 sql 语句,遇到不支持的语法就换一个数据库来跑,又不知道具体咋实现...而且还不能影响到生产环境,生产环境肯定是一直要跑 mysql 的。

查了好多教程,基本都是基于 xml 的,我不喜欢那种格式,就想着用注解实现


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK