com.github.lzj960515:easycanal-spring-boot-starter

easycanal

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.github.lzj960515
ArtifactId

ArtifactId

easycanal-spring-boot-starter
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

easycanal

Download easycanal-spring-boot-starter

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
com.github.lzj960515 : easycanal-core jar 1.0.1
org.springframework.boot : spring-boot-starter Optional jar 2.3.4.RELEASE

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