yugong 支持 SQL Server < -> MySQL

q3aa0525  于 2021-11-29  发布在  Java
关注(0)|答案(33)|浏览(545)

@agapple
我现在开发了 MySQL <-> SQL Server 的模块特性如下:

DB 支持:

  • 支持 MySQL <-> SQL Server,支持 CHECK / FULL 模式

运行环境:

  • 部署模式调整为 fat jar 模式
  • 新增特性的配置文件使用 YAML 配置

Translator 方面:

  • 支持了 MySQL 5.7 的 JSON 字段 Compress / Extract,可以将多个字段压缩进去。
  • 支持字段 NameStyle 的变化,比如将 UPPER_CAMEL 转换为 LOWER_UNDERSCORE
  • 支持了字段批量 replace 操作,比如 ID -> Id

目前已经运用到生产环境。
但是改动较大,想咨询一下,以什么样的方式提交 PR。

vojdkbi0

vojdkbi01#

@alswl 我是用git clone https://github.com/alswl/yugong.git 以及直接从releases中下载yugong-541e5f8.tar 这个,2种方式编译都报这个错

wtlkbnrh

wtlkbnrh2#

@alswl 请看下,是不是有些依赖包有变化了,编译报错了
我下载这个源码 https://github.com/alswl/yugong.git

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.072 s
[INFO] Finished at: 2018-11-27T16:53:59+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project yugong: Could not resolve dependencies for project com.taobao.yugong:yugong:jar:1.2.0: The following artifacts could not be resolved: com.oracle:ojdbc14:jar:10.2.0.4.0, com.beust:jcommander:jar:1.71, com.alibaba.otter:canal.client:jar:1.0.25-SNAPSHOT: Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 in central (http://repo1.maven.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

vnzz0bqm

vnzz0bqm3#

@eason0420 Oracle 的 jar 包不在 Maven Central,你需要自己去 Oracle 官网下载驱动包。
com.oracle:ojdbc14:jar:10.2.0.4.0 in central - Google Search

voj3qocg

voj3qocg4#

@alswl jcommander:1.71这个jar也没有,我在pom中改成1.72版本是可以编译的,但过程还是有错,是不是与这个jar包版本有关,能先提供个编译好的jar包吗?

[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[478] (indentation) Indentation: 'if' child have incorrect indentation level 20, expected level should be 10.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[480] (indentation) Indentation: 'if' child have incorrect indentation level 20, expected level should be 10.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[481] (indentation) Indentation: 'if' child have incorrect indentation level 20, expected level should be 10.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[482] (indentation) Indentation: 'if' child have incorrect indentation level 20, expected level should be 10.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[483] (indentation) Indentation: 'if' child have incorrect indentation level 20, expected level should be 10.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[484] (indentation) Indentation: 'if rcurly' have incorrect indentation level 16, expected level should be 8.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[485] (indentation) Indentation: 'synchronized rcurly' have incorrect indentation level 12, expected level should be 6.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[486] (indentation) Indentation: 'if rcurly' have incorrect indentation level 8, expected level should be 4.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[488] (indentation) Indentation: 'method def' child have incorrect indentation level 8, expected level should be 4.
[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[489] (indentation) Indentation: 'method def rcurly' have incorrect indentation level 4, expected level should be 2.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[118,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[130,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[142,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Appiler.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Appiler.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Extractor.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Extractor.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Table.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Table.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
[WARNING] checkstyle:check violations detected but failOnViolation set to false

laawzig2

laawzig25#

@alswl 我用git clone下载的源码编译成功不了,但用下载的yugong-1.0.3版本的源码可以编译成功,但是没有生成yugong-shaded.jar而是生成了yugong-1.0.3.jar,这2个有什么区别?1.0.3支持mssql-->mysql吗

unguejic

unguejic6#

我修复了一个 maven 依赖问题,可以正常编译了。

o4tp2gmn

o4tp2gmn8#

@alswl 感谢,我这边编译还是有些错,与JDK版本有关系吗?我的是java version "1.8.0_191"

我先用你提供的编译好的jar包测试下

[ERROR] src/main/java/com/taobao/yugong/applier/FullRecordApplier.java:[489] (indentation) Indentation: 'method def rcurly' have incorrect indentation level 4, expected level should be 2.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[118,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[130,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/applier/AbstractRecordApplier.java:[142,9] (naming) LocalVariableName: Local variable name 'i' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Appiler.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Appiler.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Extractor.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Extractor.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Table.java:[7,18] (naming) MemberName: Member name 'a' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]
$'.
[ERROR] src/main/java/com/taobao/yugong/conf/Table.java:[8,18] (naming) MemberName: Member name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.

bpsygsoo

bpsygsoo9#

我本地版本也是 1.8.0_192,我看你这个错误都是格式检查报错。你确认一下使用的 git 版本是 541e5f8

bzzcjhmw

bzzcjhmw12#

@wavelet123 如果是我那个版本参考 https://github.com/alswl/yugong/blob/feature/sql-server-to-mysql-overview/src/it/resources/sample_config/2_mysql-mssql-check.yaml#L61

如果是官方版本自己定制一个 Translator
https://github.com/alibaba/yugong/blob/master/src/main/java/com/taobao/yugong/translator/DataTranslator.java

5jdjgkvh

5jdjgkvh13#

@alswl ,我的target表比souce多一个id字段,这个yugong能处理吗?应该怎么配置?

zte4gxcn

zte4gxcn14#

@eason0420 字段Map:https://github.com/alswl/yugong/blob/feature/sql-server-to-mysql-overview/yugong.yaml.sample#L50

大小写设置:https://github.com/alswl/yugong/blob/feature/sql-server-to-mysql-overview/yugong.yaml.sample#L55 这是统一处理,处理之后还可以用 column_alias 做个性化处理。

yxyvkwin

yxyvkwin15#

@alswl 能提供一个yaml文件的配置案列吗?整库多个表,字段名不同的Map,以及目标和源库表中字段不一样如何设置等 ,还有就是表名以及列名的大小写不一样的话怎么处理 自己琢磨总是不成功。

相关问题