com.github.lzj960515:easycanal-core

easycanal

License

License

GroupId

GroupId

com.github.lzj960515
ArtifactId

ArtifactId

easycanal-core
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

easycanal

Download easycanal-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lzj960515/easycanal-core/ -->
<dependency>
    <groupId>com.github.lzj960515</groupId>
    <artifactId>easycanal-core</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.lzj960515/easycanal-core/
implementation 'com.github.lzj960515:easycanal-core:1.0.1'
// https://jarcasting.com/artifacts/com.github.lzj960515/easycanal-core/
implementation ("com.github.lzj960515:easycanal-core:1.0.1")
'com.github.lzj960515:easycanal-core:jar:1.0.1'
<dependency org="com.github.lzj960515" name="easycanal-core" rev="1.0.1">
  <artifact name="easycanal-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.lzj960515', module='easycanal-core', version='1.0.1')
)
libraryDependencies += "com.github.lzj960515" % "easycanal-core" % "1.0.1"
[com.github.lzj960515/easycanal-core "1.0.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter Optional jar 2.3.4.RELEASE
org.springframework.boot : spring-boot-configuration-processor jar 2.3.4.RELEASE
com.alibaba.otter : canal.client jar 1.1.4
org.projectlombok : lombok jar 1.18.16

Project Modules

There are no modules declared in this project.

easycanal

简化canal的使用方式,集成Spring, 只需加上配置与相应的注解,即可像MQ一样使用canal

使用方式

  • starter方式

    • 引入easycanal-spring-boot-starter依赖

       <dependency>
              <groupId>com.github.lzj960515</groupId>
              <artifactId>easycanal-spring-boot-starter</artifactId>
              <version>1.0.1</version>
       </dependency>
    • 编写配置

       canal:
         server:
           host: 127.0.0.1
           port: 11111
           destination: example
           username: canal
           password: canal 
    • 在使用的方法上加上@OnCanalMessage注解

          @Service
          public class DemoService {
          
              @OnCanalMessage(schemaName = "test", tableName = "fruit", id = "id", eventType = EventType.INSERT)
              public void onInsertMessage(CanalMessage canalMessage){
                  System.out.println("监听到表test.fruit插入");
                  Map<String, String> allColumn = canalMessage.getAllColumn();
                  Map<String, String> onlyUpdateColumn = canalMessage.getOnlyUpdateColumn();
                  System.out.println("所有列:" + allColumn);
                  System.out.println("更新了的列" + onlyUpdateColumn);
              }
          }

      schemaName: 数据库名
      tableName: 表名
      id: 表的主键
      eventType: 事件类型

Versions

Version
1.0.1
1.0.0