From 5ce30ca51683a84b5b2152cbde6cb2bcd5170f0c Mon Sep 17 00:00:00 2001 From: linghengqian Date: Wed, 3 Jan 2024 00:30:13 +0800 Subject: [PATCH] Fixes CI errors caused by Druid changes --- CONTRIBUTING.md | 7 ++--- README.md | 4 +++ dynamic-datasource-spring-boot-common/pom.xml | 5 ---- .../pom.xml | 5 ++++ .../DruidDynamicDataSourceConfiguration.java | 0 .../pom.xml | 7 ++++- .../DruidDynamicDataSourceConfiguration.java | 30 +++++++++++++++++++ native-image/extra-filter.json | 29 ++++++++++-------- 8 files changed, 64 insertions(+), 23 deletions(-) rename {dynamic-datasource-spring-boot-common => dynamic-datasource-spring-boot-starter}/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java (100%) create mode 100644 dynamic-datasource-spring-boot3-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11f5b272..71070dcd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ Git Mirror 位于 https://github.com/baomidou/dynamic-datasource 。 当项目导入 IntelliJ IDEA 或 VSCode 时,IDE 对项目的语言级别应当设置为 8。 对于单独的 `com.baomidou:dynamic-datasource-spring-boot3-starter` 子模块,IDE 的语言级别应当设置为 17。 -提交 PR 前,应在 OpenJDK 17 下执行 `./mvnw -T1C -B clean test` 以验证更改是否未破坏单元测试。若有需要请补充或更改单元测试。 +提交 PR 前,应在 OpenJDK 17 下执行 `./mvnw -T1C clean test` 以验证更改是否未破坏单元测试。若有需要请补充或更改单元测试。 假设贡献者处于新的 Ubuntu 22.04.3 LTS 实例下,其可通过如下 bash 命令来通过 SDKMAN! 管理 JDK 和工具链,并执行单元测试。 @@ -22,7 +22,7 @@ sdk use java 17.0.8-ms git clone git@github.com:baomidou/dynamic-datasource.git cd ./dynamic-datasource/ -./mvnw -T1C -B clean test +./mvnw -T1C clean test ``` ## 2.1. Execute NativeTest under GraalVM Native Image @@ -68,7 +68,7 @@ System Property 屏蔽部分单元测试在 GraalVM Native Image 下运行。 已有的 GraalVM Reachability Metadata 文件。可通过如下 bash 命令简单处理此流程。贡献者仍可能需要手动调整具体的 JSON 条目,并在适当的时候 调整 Maven Profile 和 GraalVM Tracing Agent 的 Filter 链。 -以下命令仅为 `dynamic-datasource-spring-boot3-starter` 生成 Conditioanl 形态的 GraalVM Reachability Metadata 的一个举例。 +以下命令仅为 `dynamic-datasource-spring-boot3-starter` 生成 Conditional 形态的 GraalVM Reachability Metadata 的一个举例。 对于测试类和测试文件独立使用的 GraalVM Reachability Metadata,贡献者应该放置到相关子模块对应的 `${project.basedir}/src/test/resources/META-INF/native-image/${project.artifactId}-test-metadata/` 文件夹下。`${}` 内为 @@ -78,7 +78,6 @@ POM 4.0 的常规系统变量,自行替换。 git clone git@github.com:baomidou/dynamic-datasource.git cd ./dynamic-datasource/ ./mvnw -PgenerateMetadata -DskipNativeTests -e -T1C clean test native:metadata-copy -./mvnw -PnativeTestInSpringBoot -T1C -e clean test ``` 请手动删除无任何具体条目的 JSON 文件。 diff --git a/README.md b/README.md index e0391e05..a487577c 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ dynamic-datasource-spring-boot-starter 是一个基于springboot的快速集成 详细文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611 +## 贡献 | Contributing + +我们欢迎社区的贡献,请查看 [CONTRIBUTING.md](./CONTRIBUTING.md) 。 + # 特性 - 支持 **数据源分组** ,适用于多种场景 纯粹多库 读写分离 一主多从 混合模式。 diff --git a/dynamic-datasource-spring-boot-common/pom.xml b/dynamic-datasource-spring-boot-common/pom.xml index 97330ae2..d3a5e878 100644 --- a/dynamic-datasource-spring-boot-common/pom.xml +++ b/dynamic-datasource-spring-boot-common/pom.xml @@ -56,11 +56,6 @@ org.springframework.boot spring-boot-starter-aop - - com.alibaba - druid-spring-boot-starter - true - org.springframework.boot spring-boot-configuration-processor diff --git a/dynamic-datasource-spring-boot-starter/pom.xml b/dynamic-datasource-spring-boot-starter/pom.xml index cbbb5fbd..628d8f4d 100644 --- a/dynamic-datasource-spring-boot-starter/pom.xml +++ b/dynamic-datasource-spring-boot-starter/pom.xml @@ -24,6 +24,11 @@ spring-boot-starter-web true + + com.alibaba + druid-spring-boot-starter + true + org.springframework.boot spring-boot-configuration-processor diff --git a/dynamic-datasource-spring-boot-common/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java b/dynamic-datasource-spring-boot-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java similarity index 100% rename from dynamic-datasource-spring-boot-common/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java rename to dynamic-datasource-spring-boot-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java diff --git a/dynamic-datasource-spring-boot3-starter/pom.xml b/dynamic-datasource-spring-boot3-starter/pom.xml index d00f7947..9da9b660 100644 --- a/dynamic-datasource-spring-boot3-starter/pom.xml +++ b/dynamic-datasource-spring-boot3-starter/pom.xml @@ -16,7 +16,7 @@ 17 - 3.2.1 + 3.1.5 @@ -29,6 +29,11 @@ spring-boot-starter-web true + + com.alibaba + druid-spring-boot-3-starter + true + org.springframework.boot spring-boot-configuration-processor diff --git a/dynamic-datasource-spring-boot3-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java b/dynamic-datasource-spring-boot3-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java new file mode 100644 index 00000000..a5ff7ce7 --- /dev/null +++ b/dynamic-datasource-spring-boot3-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DruidDynamicDataSourceConfiguration.java @@ -0,0 +1,30 @@ +package com.baomidou.dynamic.datasource.spring.boot.autoconfigure; + +import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure; +import com.alibaba.druid.spring.boot3.autoconfigure.properties.DruidStatProperties; +import com.alibaba.druid.spring.boot3.autoconfigure.stat.DruidFilterConfiguration; +import com.alibaba.druid.spring.boot3.autoconfigure.stat.DruidSpringAopConfiguration; +import com.alibaba.druid.spring.boot3.autoconfigure.stat.DruidStatViewServletConfiguration; +import com.alibaba.druid.spring.boot3.autoconfigure.stat.DruidWebStatFilterConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * 从原生DruidDataSourceAutoConfigure复制 + * + * @author TaoYu + * @since 1.1.0 + */ +@Configuration +@ConditionalOnClass(DruidDataSourceAutoConfigure.class) +@EnableConfigurationProperties({DruidStatProperties.class}) +@Import({ + DruidSpringAopConfiguration.class, + DruidStatViewServletConfiguration.class, + DruidWebStatFilterConfiguration.class, + DruidFilterConfiguration.class}) +public class DruidDynamicDataSourceConfiguration { + +} diff --git a/native-image/extra-filter.json b/native-image/extra-filter.json index d4ea3b70..573c8fbc 100644 --- a/native-image/extra-filter.json +++ b/native-image/extra-filter.json @@ -1,32 +1,35 @@ { "rules": [ {"includeClasses": "**"}, + {"excludeClasses": "java.lang.management.**"}, {"excludeClasses": "jdk.management.**"}, {"excludeClasses": "com.sun.management.**"}, {"excludeClasses": "sun.management.**"}, {"excludeClasses": "javax.management.**"}, + + {"excludeClasses": "com.ibm.icu.text.**"}, {"excludeClasses": "java.**"}, {"includeClasses": "java.util.Properties"}, {"includeClasses": "java.lang.Thread"}, - {"excludeClasses": "sun.misc.**"}, - {"excludeClasses": "sun.security.**"}, - {"excludeClasses": "com.ibm.icu.text.**"}, {"excludeClasses": "javax.naming.**"}, {"excludeClasses": "javax.sql.**"}, - {"excludeClasses": "org.h2.**"}, - {"excludeClasses": "oracle.ucp.**"}, - {"excludeClasses": "org.apache.tomcat.jdbc.**"}, - {"excludeClasses": "org.apache.commons.**"}, + {"excludeClasses": "sun.misc.**"}, + {"excludeClasses": "sun.security.**"}, + + {"excludeClasses": "com.alibaba.druid.**"}, + {"excludeClasses": "com.baomidou.mybatisplus.**"}, + {"excludeClasses": "com.fasterxml.jackson.**"}, {"excludeClasses": "com.mchange.v2.**"}, {"excludeClasses": "com.zaxxer.**"}, - {"excludeClasses": "com.alibaba.druid.**"}, - {"excludeClasses": "org.springframework.**"}, - {"excludeClasses": "org.apache.ibatis.binding.**"}, {"excludeClasses": "jakarta.servlet.**"}, - {"excludeClasses": "com.fasterxml.jackson.**"}, - {"excludeClasses": "com.baomidou.mybatisplus.**"} - + {"excludeClasses": "oracle.ucp.**"}, + {"excludeClasses": "org.apache.commons.**"}, + {"excludeClasses": "org.apache.ibatis.**"}, + {"excludeClasses": "org.apache.tomcat.jdbc.**"}, + {"excludeClasses": "org.h2.**"}, + {"excludeClasses": "org.mybatis.spring.**"}, + {"excludeClasses": "org.springframework.**"} ], "regexRules": [ {"excludeClasses": ".*fixture*.*"},