From 7468644622d0b1bbf0312771d05bd2738c746484 Mon Sep 17 00:00:00 2001 From: odboy Date: Tue, 3 Dec 2024 23:12:24 +0800 Subject: [PATCH] upd --- kenaito-config-common/pom.xml | 13 ++++ kenaito-config-demo/.gitignore | 9 +++ kenaito-config-demo/pom.xml | 48 ++++++++++++++ .../src/main/java/cn/odboy/GenCode.java | 46 ++++++++++++++ .../java/cn/odboy/KenaitoConfigDemoRun.java | 24 +++++++ .../java/cn/odboy/rest/DemoController.java | 19 ++++++ .../src/main/resources/banner.txt | 8 +++ .../resources/config/application-daily.yml | 7 +++ .../config/application-production.yml | 7 +++ .../resources/config/application-stage.yml | 7 +++ .../src/main/resources/config/application.yml | 4 ++ .../main/resources/log4jdbc.log4j2.properties | 4 ++ .../src/main/resources/logback-spring.xml | 62 +++++++++++++++++++ 13 files changed, 258 insertions(+) create mode 100644 kenaito-config-common/pom.xml create mode 100644 kenaito-config-demo/.gitignore create mode 100644 kenaito-config-demo/pom.xml create mode 100644 kenaito-config-demo/src/main/java/cn/odboy/GenCode.java create mode 100644 kenaito-config-demo/src/main/java/cn/odboy/KenaitoConfigDemoRun.java create mode 100644 kenaito-config-demo/src/main/java/cn/odboy/rest/DemoController.java create mode 100644 kenaito-config-demo/src/main/resources/banner.txt create mode 100644 kenaito-config-demo/src/main/resources/config/application-daily.yml create mode 100644 kenaito-config-demo/src/main/resources/config/application-production.yml create mode 100644 kenaito-config-demo/src/main/resources/config/application-stage.yml create mode 100644 kenaito-config-demo/src/main/resources/config/application.yml create mode 100644 kenaito-config-demo/src/main/resources/log4jdbc.log4j2.properties create mode 100644 kenaito-config-demo/src/main/resources/logback-spring.xml diff --git a/kenaito-config-common/pom.xml b/kenaito-config-common/pom.xml new file mode 100644 index 0000000..68d2bcd --- /dev/null +++ b/kenaito-config-common/pom.xml @@ -0,0 +1,13 @@ + + + + kenaito-config + cn.odboy + 1.0 + + 4.0.0 + kenaito-config-common + 子模块-配置中心-公共依赖 + diff --git a/kenaito-config-demo/.gitignore b/kenaito-config-demo/.gitignore new file mode 100644 index 0000000..7c8ca6d --- /dev/null +++ b/kenaito-config-demo/.gitignore @@ -0,0 +1,9 @@ +### IDEA ### +~/* +.idea/* +*.iml +*/target/* +*/*.iml +/.gradle/ +/application.pid +/logs/application.log diff --git a/kenaito-config-demo/pom.xml b/kenaito-config-demo/pom.xml new file mode 100644 index 0000000..3cf5b42 --- /dev/null +++ b/kenaito-config-demo/pom.xml @@ -0,0 +1,48 @@ + + + + kenaito-config + cn.odboy + 1.0 + + 4.0.0 + + kenaito-config-demo + 子系统-配置使用Demo + + + UTF-8 + UTF-8 + UTF-8 + 11 + + + + + cn.odboy + kenaito-config-core + 1.0 + + + + + + kenaito-config-demo + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + diff --git a/kenaito-config-demo/src/main/java/cn/odboy/GenCode.java b/kenaito-config-demo/src/main/java/cn/odboy/GenCode.java new file mode 100644 index 0000000..df3e230 --- /dev/null +++ b/kenaito-config-demo/src/main/java/cn/odboy/GenCode.java @@ -0,0 +1,46 @@ +package cn.odboy; + + +import cn.odboy.util.GenCmdHelper; + +import java.util.List; + +/** + * 代码生成入口 + * + * @date 2024-04-27 + */ +public class GenCode { + public static void main(String[] args) { + GenCmdHelper generator = new GenCmdHelper(); + generator.setDatabaseUrl(String.format("jdbc:mysql://%s:%s/%s", "kenaito-mysql.odboy.local", 13306, "kenaito_devops")); + generator.setDatabaseUsername("root"); + generator.setDatabasePassword("root"); + genCareer(generator); + } + + private static void genCareer(GenCmdHelper generator) { + generator.gen("devops_", List.of( + // 应用 +// "devops_app", +// "devops_app_user", +// "devops_product_line", + // 应用迭代 +// "devops_app_iteration", +// "devops_app_iteration_change", + // 容器 +// "devops_containerd_cluster_config", +// "devops_containerd_cluster_node", +// "devops_ops_config", +// "devops_containerd_spec_config", + // 网络 +// "devops_network_service", +// "devops_network_ingress", + // 流水线 + "devops_pipeline_template_type", + "devops_pipeline_template_language", + "devops_pipeline_template_language_config", + "devops_pipeline_template_app" + )); + } +} diff --git a/kenaito-config-demo/src/main/java/cn/odboy/KenaitoConfigDemoRun.java b/kenaito-config-demo/src/main/java/cn/odboy/KenaitoConfigDemoRun.java new file mode 100644 index 0000000..f8092dd --- /dev/null +++ b/kenaito-config-demo/src/main/java/cn/odboy/KenaitoConfigDemoRun.java @@ -0,0 +1,24 @@ +package cn.odboy; + +import cn.odboy.infra.context.EasyBootApplication; +import cn.odboy.infra.context.SpringContextHolder; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@EnableAsync +@SpringBootApplication +@EnableTransactionManagement +public class KenaitoConfigDemoRun extends EasyBootApplication { + @Bean + public SpringContextHolder springContextHolder() { + return new SpringContextHolder(); + } + + public static void main(String[] args) { + SpringApplication springApplication = new SpringApplication(KenaitoConfigDemoRun.class); + initd(springApplication.run(args)); + } +} diff --git a/kenaito-config-demo/src/main/java/cn/odboy/rest/DemoController.java b/kenaito-config-demo/src/main/java/cn/odboy/rest/DemoController.java new file mode 100644 index 0000000..ed3b027 --- /dev/null +++ b/kenaito-config-demo/src/main/java/cn/odboy/rest/DemoController.java @@ -0,0 +1,19 @@ +package cn.odboy.rest; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/demo") +public class DemoController { + + @PostMapping("/test") + public ResponseEntity test() { + return ResponseEntity.ok("success"); + } +} diff --git a/kenaito-config-demo/src/main/resources/banner.txt b/kenaito-config-demo/src/main/resources/banner.txt new file mode 100644 index 0000000..6f82049 --- /dev/null +++ b/kenaito-config-demo/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + _ _ _____ __ _ ___ _ _____ _____ _____ _____ __ _ _____ _ _____ +| | / / | ____| | \ | | / | | | |_ _| / _ \ / ___| / _ \ | \ | | | ___| | | / ___| +| |/ / | |__ | \| | / /| | | | | | | | | | | | | | | | | \| | | |__ | | | | +| |\ \ | __| | |\ | / / | | | | | | | | | | | | | | | | | |\ | | __| | | | | _ +| | \ \ | |___ | | \ | / / | | | | | | | |_| | | |___ | |_| | | | \ | | | | | | |_| | +|_| \_\ |_____| |_| \_| /_/ |_| |_| |_| \_____/ \_____| \_____/ |_| \_| |_| |_| \_____/ + + :: Spring Boot :: (v2.7.18) diff --git a/kenaito-config-demo/src/main/resources/config/application-daily.yml b/kenaito-config-demo/src/main/resources/config/application-daily.yml new file mode 100644 index 0000000..0116afc --- /dev/null +++ b/kenaito-config-demo/src/main/resources/config/application-daily.yml @@ -0,0 +1,7 @@ +kenaito: + config-center: + server: 127.0.0.1 + port: 28002 + data-id: kenaito-config-service + cache-dir: c:\\data + env: daily \ No newline at end of file diff --git a/kenaito-config-demo/src/main/resources/config/application-production.yml b/kenaito-config-demo/src/main/resources/config/application-production.yml new file mode 100644 index 0000000..f287a61 --- /dev/null +++ b/kenaito-config-demo/src/main/resources/config/application-production.yml @@ -0,0 +1,7 @@ +kenaito: + config-center: + server: 127.0.0.1 + port: 28002 + data-id: kenaito-config-service + cache-dir: /home/admin/data + env: production \ No newline at end of file diff --git a/kenaito-config-demo/src/main/resources/config/application-stage.yml b/kenaito-config-demo/src/main/resources/config/application-stage.yml new file mode 100644 index 0000000..27d1273 --- /dev/null +++ b/kenaito-config-demo/src/main/resources/config/application-stage.yml @@ -0,0 +1,7 @@ +kenaito: + config-center: + server: 127.0.0.1 + port: 28002 + data-id: kenaito-config-service + cache-dir: /home/admin/data + env: stage \ No newline at end of file diff --git a/kenaito-config-demo/src/main/resources/config/application.yml b/kenaito-config-demo/src/main/resources/config/application.yml new file mode 100644 index 0000000..7a1ea5c --- /dev/null +++ b/kenaito-config-demo/src/main/resources/config/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + # 激活哪个配置文件, application-{active}.yml + active: daily diff --git a/kenaito-config-demo/src/main/resources/log4jdbc.log4j2.properties b/kenaito-config-demo/src/main/resources/log4jdbc.log4j2.properties new file mode 100644 index 0000000..302525f --- /dev/null +++ b/kenaito-config-demo/src/main/resources/log4jdbc.log4j2.properties @@ -0,0 +1,4 @@ +# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger +log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator +log4jdbc.auto.load.popular.drivers=false +log4jdbc.drivers=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/kenaito-config-demo/src/main/resources/logback-spring.xml b/kenaito-config-demo/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..56e8473 --- /dev/null +++ b/kenaito-config-demo/src/main/resources/logback-spring.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + ${LOG_PATTERN} + + + + + + ${LOG_HOME}/application.log + + + ${LOG_HOME}/application.log.%d{yyyy-MM-dd}.%i.log + + 30 + + 1000MB + + + + + ${LOG_PATTERN} + + + + + + + + + + + + + + + + + + + + + + + + + + +