这是flyway maven插件配置:
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<sqlMigrationSuffix>.oracle.sql</sqlMigrationSuffix>
<placeholderReplacement>true</placeholderReplacement>
<placeholderPrefix>#[</placeholderPrefix>
<placeholderSuffix>]</placeholderSuffix>
<encoding>UTF-8</encoding>
<table>T00M001</table>
<locations>
<location>classpath:/META-INF/flyway/oracle</location>
<location>classpath:/com/chorke/dbms/jdbcmi/oracle</location>
</locations>
<resolvers>
<resolver>com.chorke.dbms.flyway.resolvers.FlywayResolverImpl</resolver>
</resolvers>
<callbacks>
<callback>com.chorke.dbms.flyway.callbacks.AfterEachMigrate</callback>
<callback>com.chorke.dbms.flyway.callbacks.BeforeEachMigrate</callback>
</callbacks>
<serverId>chorke.flyway.oracle</serverId>
<url>jdbc:oracle:thin:@127.0.0.1:1521:xe</url>
</configuration>
<dependencies>
<dependency>
<groupId>com.chorke.dbms</groupId>
<artifactId>chorke-dbms-flyway</artifactId>
<version>1.0.00-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.chorke.dbms</groupId>
<artifactId>chorke-dbms-oracle</artifactId>
<version>1.0.00-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.chorke.dbms</groupId>
<artifactId>chorke-dbms-jdbcmi</artifactId>
<version>1.0.00-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
这是 flyway.properties
flyway.encoding: UTF-8
flyway.placeholders.key: value
flyway.placeholders.name: nome
flyway.placeholders.prop: value
以下是迁移脚本的片段:
-- DDL OF T01I001
-- -----------------------------------------------------------------------------
CREATE TABLE t01i001
(
t_msg_code VARCHAR2(5 BYTE) NOT NULL
, t_lang1_msg VARCHAR2(80 BYTE)
, t_lang2_msg VARCHAR2(80 BYTE)
, t_entry_user VARCHAR2(4 BYTE)
, t_entry_date DATE
, t_upd_user VARCHAR2(4 BYTE)
, t_upd_date DATE
);
-- DML OF T01I001
-- -----------------------------------------------------------------------------
INSERT INTO t01i001 (t_msg_code,t_lang1_msg,t_lang2_msg,t_entry_user
,t_entry_date,t_upd_user,t_upd_date) VALUES ('00','يوجد سجل أخر لليوم والوقت المحدد'
,'Record already exists for the specified Date and Time.','2'
,to_date('13-10-2005','DD-MM-YYYY'),'C',to_date('27-11-2005','DD-MM-YYYY'));
INSERT INTO t01i001 (t_msg_code,t_lang1_msg,t_lang2_msg,t_entry_user
,t_entry_date,t_upd_user,t_upd_date) VALUES ('01'
,'البيانات قد أدخلت من قبل لرقم الزيارة هذا'
,'Data has already been entered for this Visit Number.','2'
,to_date('13-10-2005','DD-MM-YYYY'),'C',to_date('27-11-2005','DD-MM-YYYY'));
这是oracle 11g XE R2 charset的注册表:
NLS_LANG =AMERICAN_AMERICA.UTF8
这是maven的目标:
mvn clean install flyway:migrate flyway:info
发生了两种类型的问题:
虽然我们增加 t_lang1_msg 大小比迁移工作正常。但它会自动转换为يوجدسجلأخرلليوموالوقتالمحدد到ÙŠÙجدسجٓأخرٔٓيÙÙ...ÙأÙÙ,ØªØ §Ù“U ... OOO 即可。哪一个对我们来说是不可读的。
有关此问题的任何解决方案?感谢您解决此问题的答案。
答案 0 :(得分:0)
实际上毫无疑问 flyway-maven-plugin , flyway.properties 的配置以及sql脚本及其编码。但是在ant脚本目标中存在问题。每个sprint基于特定顺序的concat
sql文件的任务。如下:
<concat destfile="${file.flyway.sql.concat}" outputencoding="UTF-8"append="true">
<sort xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
<fileset refid="dir.set.flyway.db.version.build"/>
<rcmp:name />
</sort>
</concat>
将encoding="UTF-8"
属性添加到concat任务后,它正常工作。
<concat destfile="${file.flyway.sql.concat}"
outputencoding="UTF-8" encoding="UTF-8" append="true">
<sort xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
<fileset refid="dir.set.flyway.db.version.build"/>
<rcmp:name />
</sort>
</concat>
这解决了这个问题。