flyway初始化脚本存在默认特殊字符的问题处理
2015-12-15 11:13
381 查看
一、问题描述
在用flyway管理数据库脚本时,脚本中存在insert初始化语句,而insert中value值存在$(**)这种模板数据格式,导致启动时flyway报错,错误信息如下:
二、问题定位
查看org.flywaydb.core.internal.util.PlaceholderReplacer.checkForUnmatchedPlaceholderExpression源码分析:
发现placeholderPrefix和placeholderSuffix默认表达式为:$(和),所以如果脚本中存在此类特殊符就会导致冲突。
/**
* The prefix of every placeholder. Usually ${
*/
private final String placeholderPrefix;
/**
* The suffix of every placeholder. Usually }
*/
private final String placeholderSuffix;
三、解决方法
1、修改默认placeholderPrefix和placeholderSuffix
flyway.setPlaceholderPrefix("#(");
flyway.setPlaceholderSuffix(")");
2、insert table1(c1) value (replace('%{x}','%','$')
用replace 规避了直接写 ${x}
在用flyway管理数据库脚本时,脚本中存在insert初始化语句,而insert中value值存在$(**)这种模板数据格式,导致启动时flyway报错,错误信息如下:
二、问题定位
查看org.flywaydb.core.internal.util.PlaceholderReplacer.checkForUnmatchedPlaceholderExpression源码分析:
发现placeholderPrefix和placeholderSuffix默认表达式为:$(和),所以如果脚本中存在此类特殊符就会导致冲突。
/**
* The prefix of every placeholder. Usually ${
*/
private final String placeholderPrefix;
/**
* The suffix of every placeholder. Usually }
*/
private final String placeholderSuffix;
三、解决方法
1、修改默认placeholderPrefix和placeholderSuffix
flyway.setPlaceholderPrefix("#(");
flyway.setPlaceholderSuffix(")");
2、insert table1(c1) value (replace('%{x}','%','$')
用replace 规避了直接写 ${x}
相关文章推荐
- android AsyncTask异步调用方法
- 一位上了一个大的互联网公司笔试题分享
- linux ntp时间同步
- 【转】Pro Android学习笔记(六):了解Content Provider(中)
- 【C#】菜单
- Kinect for Windows SDK开发入门(四):景深数据处理 上
- 【Android】wifi开发
- GLSurfaceView简介
- mongodb使用2
- Git 通过submodule添加子项目/库。
- 绝望的主妇追剧感悟
- leetcode -- Palindrome Partitioning -- 重点 dfs
- android签名机制
- struts2结合axis开发webservice
- 闭包函数和匿名函数的关系
- curl libcurl 编译依赖库 安装
- 关于 DOM 操作的几个类型
- [ 1001 ]10 只耗子和1000 瓶水的故事 二进制 数据敏感性
- java实现投票程序设计
- squid介绍及其简单配置