Skip to content

Commit

Permalink
Fixes CI errors caused by Druid and Spring Framework changes (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
linghengqian authored Jan 3, 2024
1 parent 8f633a5 commit 620444c
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 30 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
test-graalvm-ce-ci:
name: NativeTest CI - GraalVM CE ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
timeout-minutes: 30
continue-on-error: true
strategy:
matrix:
os: [ ubuntu-latest ]
java-version: [ '21' ]
java-version: [ '21.0.1' ]
steps:
- uses: actions/checkout@v3
- uses: graalvm/setup-graalvm@v1
Expand All @@ -48,11 +48,11 @@ jobs:
test-hotspot-jdk-ci:
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
timeout-minutes: 30
strategy:
matrix:
os: [ ubuntu-latest ]
java-version: [ '17', '21-ea' ]
java-version: [ '17', '21' ]
steps:
- uses: actions/checkout@v3
- name: Setup java
Expand All @@ -67,7 +67,7 @@ jobs:
test-minimum-jdk-ci:
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
timeout-minutes: 30
strategy:
matrix:
os: [ ubuntu-latest ]
Expand Down
11 changes: 5 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 和工具链,并执行单元测试。

Expand All @@ -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
Expand All @@ -41,8 +41,8 @@ failed to discover tests 的测试库。
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21-graalce
sdk use java 21-graalce
sdk install java 21.0.1-graalce
sdk use java 21.0.1-graalce
sudo apt-get install build-essential libz-dev zlib1g-dev -y

git clone git@github.com:baomidou/dynamic-datasource.git
Expand All @@ -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/` 文件夹下。`${}` 内为
Expand All @@ -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 文件。
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ dynamic-datasource-spring-boot-starter 是一个基于springboot的快速集成

详细文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611

## 贡献 | Contributing

我们欢迎社区的贡献,请查看 [CONTRIBUTING.md](./CONTRIBUTING.md)

# 特性

- 支持 **数据源分组** ,适用于多种场景 纯粹多库 读写分离 一主多从 混合模式。
Expand Down
5 changes: 0 additions & 5 deletions dynamic-datasource-spring-boot-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions dynamic-datasource-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions dynamic-datasource-spring-boot3-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

}
27 changes: 15 additions & 12 deletions native-image/extra-filter.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
{
"rules": [
{"includeClasses": "**"},

{"excludeClasses": "java.lang.management.**"},
{"excludeClasses": "jdk.management.**"},
{"excludeClasses": "com.sun.management.**"},
{"excludeClasses": "sun.management.**"},
{"excludeClasses": "javax.management.**"},

{"excludeClasses": "java.**"},
{"includeClasses": "java.util.Properties"},
{"includeClasses": "java.lang.Thread"},
{"excludeClasses": "javax.naming.**"},
{"excludeClasses": "javax.sql.**"},
{"excludeClasses": "sun.misc.**"},
{"excludeClasses": "sun.security.**"},

{"excludeClasses": "com.alibaba.druid.**"},
{"excludeClasses": "com.baomidou.mybatisplus.**"},
{"excludeClasses": "com.fasterxml.jackson.**"},
{"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": "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*.*"},
Expand Down
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
<lombok.version>1.18.30</lombok.version>
<h2.version>2.2.224</h2.version>
<atomikos.version>4.0.6</atomikos.version>
<junit-jupiter.version>5.10.0</junit-jupiter.version>
<junit-jupiter.version>5.10.1</junit-jupiter.version>

<maven-clean-plugin.version>3.3.1</maven-clean-plugin.version>
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>3.6.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
Expand Down Expand Up @@ -222,6 +222,8 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- Refer to https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention -->
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
Expand Down

0 comments on commit 620444c

Please sign in to comment.