From d5af00ca195b698586c82d05db3692e17a85203c Mon Sep 17 00:00:00 2001 From: yaoq Date: Mon, 19 Sep 2022 19:51:49 +0800 Subject: [PATCH] =?UTF-8?q?canal=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smtweb-framework/canal/client/canal.example.iml | 4 +- .../client/src/main/resources/client.properties | 6 ++ smtweb-framework/canal/file/pom.xml | 108 +++++++++++++++++++++ .../smtweb/system/canal/file/FileApplication.java | 13 +++ .../system/canal/file/FileConfiguration.java | 21 ++++ .../system/canal/file/FileStartedListener.java | 41 ++++++++ .../src/main/resources/META-INF/spring.factories | 2 + .../src/main/resources/config/application.yaml | 102 +++++++++++++++++++ smtweb-framework/canal/server/canal.deployer.iml | 4 +- 9 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 smtweb-framework/canal/file/pom.xml create mode 100644 smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileApplication.java create mode 100644 smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileConfiguration.java create mode 100644 smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileStartedListener.java create mode 100644 smtweb-framework/canal/file/src/main/resources/META-INF/spring.factories create mode 100644 smtweb-framework/canal/file/src/main/resources/config/application.yaml diff --git a/smtweb-framework/canal/client/canal.example.iml b/smtweb-framework/canal/client/canal.example.iml index e51cbbd..c02bc28 100644 --- a/smtweb-framework/canal/client/canal.example.iml +++ b/smtweb-framework/canal/client/canal.example.iml @@ -9,7 +9,9 @@ - + + + diff --git a/smtweb-framework/canal/client/src/main/resources/client.properties b/smtweb-framework/canal/client/src/main/resources/client.properties index df6ae7f..d49f6c9 100644 --- a/smtweb-framework/canal/client/src/main/resources/client.properties +++ b/smtweb-framework/canal/client/src/main/resources/client.properties @@ -12,5 +12,11 @@ canal.server.password= canal.server.filter=scmz\\..* # 文件存放路径 E:/canalFile canal.file.path= +# mysql、dmsql、kbsql、oracle +canal.db.type=kbsql +canal.db.driverName=com.kingbase8.Driver +canal.db.jdbcUrl=jdbc:kingbase8://172.28.123.205:54321/HLJTY?useUnicode=true&characterEncoding=utf-8 +canal.db.username=system +canal.db.password=system diff --git a/smtweb-framework/canal/file/pom.xml b/smtweb-framework/canal/file/pom.xml new file mode 100644 index 0000000..cc63eac --- /dev/null +++ b/smtweb-framework/canal/file/pom.xml @@ -0,0 +1,108 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.9 + + + + cc.smtweb + canal.file + 1.1.5 + + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.springframework.boot + spring-boot-devtools + true + + + + + + cc.smtweb + sw-system-bpm + 3.1.0-SNAPSHOT + + + + cc.smtweb + sw-framework-core + 3.1.0-SNAPSHOT + + + + cc.smtweb + canal.example + 1.1.5 + + + + cc.smtweb + canal.deployer + 1.1.5 + + + + + com.kingbase8 + kingbase8 + 8.6.0 + + + + com.dmsql + dmsql + 1.0.0 + + + cc.smtweb + canal.deployer + 1.1.5 + compile + + + + + + + nexus-jjkj + Nexus jjkj + http://47.92.149.153:7000/repository/maven-public/ + + true + + + true + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileApplication.java b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileApplication.java new file mode 100644 index 0000000..b93cdea --- /dev/null +++ b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileApplication.java @@ -0,0 +1,13 @@ +package cc.smtweb.system.canal.file; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class FileApplication { + + public static void main(String[] args) { + SpringApplication.run(FileApplication.class, args); + } + +} diff --git a/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileConfiguration.java b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileConfiguration.java new file mode 100644 index 0000000..5cf4db8 --- /dev/null +++ b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileConfiguration.java @@ -0,0 +1,21 @@ +package cc.smtweb.system.canal.file; + +import cc.smtweb.framework.core.mvc.config.ControllerConfig; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @author kevin + */ +@Configuration +@ComponentScan +public class FileConfiguration { + /** + * 配置自定义service扫描路径 {module}/{service}/{method} + */ + @Bean + public ControllerConfig canalConfiguration() { + return new ControllerConfig("canalFile", "cc.smtweb.system.canal.file", null); + } +} diff --git a/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileStartedListener.java b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileStartedListener.java new file mode 100644 index 0000000..1410876 --- /dev/null +++ b/smtweb-framework/canal/file/src/main/java/cc/smtweb/system/canal/file/FileStartedListener.java @@ -0,0 +1,41 @@ +package cc.smtweb.system.canal.file; + +import cc.smtweb.framework.core.annotation.SwStartListener; +import cc.smtweb.framework.core.common.SwConsts; +import cc.smtweb.framework.core.mvc.controller.IStartListener; +import cc.smtweb.framework.core.systask.SysThreadPool; +import cc.smtweb.framework.core.systask.SysThreadWorker; +import cc.smtweb.system.canal.deployer.CanalLauncher; +import lombok.extern.slf4j.Slf4j; + +/** + * @Author yaoq + * @Date 2022年09月06日 10:31 + * @Description + */ +@Slf4j +@SwStartListener +public class FileStartedListener implements IStartListener { + + @Override + public int order() { + return SwConsts.DEFAULT_ORDER + 3; + } + + + @Override + public void init() { + SwConsts.SysParam.enableCanal = true; + } + + @Override + public void run() { + if (!SwConsts.SysParam.enableCanal) return; + SysThreadPool.getInstance().addTask(new SysThreadWorker("canal server") { + @Override + public void localWork() throws Exception { + CanalLauncher.startServer(); + } + }); + } +} diff --git a/smtweb-framework/canal/file/src/main/resources/META-INF/spring.factories b/smtweb-framework/canal/file/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..4cbcd4f --- /dev/null +++ b/smtweb-framework/canal/file/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + cc.smtweb.system.canal.file.FileConfiguration diff --git a/smtweb-framework/canal/file/src/main/resources/config/application.yaml b/smtweb-framework/canal/file/src/main/resources/config/application.yaml new file mode 100644 index 0000000..f61bce2 --- /dev/null +++ b/smtweb-framework/canal/file/src/main/resources/config/application.yaml @@ -0,0 +1,102 @@ +smtweb: + machine-id: 1 + enable-job: false + bpm: + mode: 1 + debug: true + code-java-path: 'd:/work/smtweb2/smtweb-framework/canal/file' + db: + type: mysql + default: + rule: + prefix: _smt_ + replace: smt_ + # 服务模块 +devtools: + restart: + enabled: true # 热部署开关 + additional-paths: src/main/java #重启目录 +server: + port: 8888 + servlet: + context-path: +logging: + level: + root: INFO + cc.smtweb: DEBUG +spring: + redis: + host: 127.0.0.1 + port: 6379 + password: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + # url: jdbc:mysql://139.9.38.43:6032/smt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + url: jdbc:mysql://172.28.123.145:4418/smt?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + username: root + password: Ncmz@2022_jjkj + servlet: + multipart: + max-file-size: 104857600000 + max-request-size: 10485760000000 + cache: + type: caffeine + cache-names: + - core + - bpm + caffeine: + spec: maximumSize=1024,expireAfterWrite=2h + +# canal配置 +canal: + file: + +# http 规则配置 +http-config: + xss: #xss 规则 + checkHeader: false #是否进行header校验 + checkParameter: true #是否进行parameter校验 + logIs: true #是否记录日志 + chain: true #是否中断请求 + replace: true #是否开启特殊字符替换 + checkUrl: true #是否开启特殊url校验 + regex: + # 匹配含有字符: alert( ) + - .*[A|a][L|l][E|e][R|r][T|t](.*).* + # 匹配含有字符: window.location + - .*[W|w][I|i][N|n][D|d][O|o][W|w].[L|l][O|o][C|c][A|a][T|t][I|i][O|o][N|n].* + # 匹配含有字符:style = x:ex pression ( ) + - .*[S|s][T|t][Y|y][L|l][E|e]\\s*=.*[X|x]:[E|e][X|x].*[P|p][R|r][E|e][S|s]{1,2}[I|i][O|o][N|n]\\s*\\(.*\\).* + # 匹配含有字符: document.cookie + - .*[D|d][O|o][C|c][U|u][M|m][E|e][N|n][T|t].[C|c][O|o]{2}[K|k][I|i][E|e].* + # 匹配含有字符: eval( ) + - .*[E|e][V|v][A|a][L|l](.*).* + # 匹配含有字符: unescape() + - .*[U|u][N|n][E|e][S|s][C|c][A|a][P|p][E|e](.*).* + # 匹配含有字符: execscript( ) + - .*[E|e][X|x][E|e][C|c][S|s][C|c][R|r][I|i][P|p][T|t](.*).* + # 匹配含有字符: msgbox( ) + - .*[M|m][S|s][G|g][B|b][O|o][X|x](.*).* + # 匹配含有字符: confirm( ) + - .*[C|c][O|o][N|n][F|f][I|i][R|r][M|m](.*).* + # 匹配含有字符: prompt( ) + - .*[P|p][R|r][O|o][M|m][P|p][T|t](.*).* + # 匹配含有字符: + - .*<[S|s][C|c][R|r][I|i][P|p][T|t]>.*.*.* + # 匹配含有字符: + - .*.* + # 匹配含有字符: