Open and Fix NativeTest by Spring Framework under GraalVM CE (#562)
This commit is contained in:
parent
8e8e098208
commit
0d963934ac
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -24,7 +24,6 @@ env:
|
|||||||
MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true
|
MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# TODO
|
|
||||||
test-graalvm-ce-ci:
|
test-graalvm-ce-ci:
|
||||||
name: NativeTest CI - GraalVM CE ${{ matrix.java-version }} on ${{ matrix.os }} (This CI failure is reasonable)
|
name: NativeTest CI - GraalVM CE ${{ matrix.java-version }} on ${{ matrix.os }} (This CI failure is reasonable)
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -45,7 +44,7 @@ jobs:
|
|||||||
- name: Build Spring Boot Starter 3 test with Maven
|
- name: Build Spring Boot Starter 3 test with Maven
|
||||||
run: |
|
run: |
|
||||||
./mvnw -T1C -B -PgenerateMetadata -DskipNativeTests clean test
|
./mvnw -T1C -B -PgenerateMetadata -DskipNativeTests clean test
|
||||||
# ./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot T1C -B clean test
|
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B clean test
|
||||||
test-maximum-jdk-ci:
|
test-maximum-jdk-ci:
|
||||||
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
|
name: Test CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -52,7 +52,7 @@ cd ./dynamic-datasource/
|
|||||||
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B clean test
|
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B clean test
|
||||||
```
|
```
|
||||||
|
|
||||||
贡献者在提交 PR 后,位于 Github Actions 的 CI 将进行此验证。相关 CI 的失败行为是现阶段是可接受的。
|
贡献者在提交 PR 后,位于 Github Actions 的 CI 将进行此验证。
|
||||||
|
|
||||||
请不要为 SPEL 功能编写可能的 nativeTest,参考 https://github.com/spring-projects/spring-framework/issues/29548 。如有需要,
|
请不要为 SPEL 功能编写可能的 nativeTest,参考 https://github.com/spring-projects/spring-framework/issues/29548 。如有需要,
|
||||||
请使用 `org.graalvm.nativeimage.imagecode` 的 System Property 屏蔽相关测试在 GraalVM Native Image 下运行。
|
请使用 `org.graalvm.nativeimage.imagecode` 的 System Property 屏蔽相关测试在 GraalVM Native Image 下运行。
|
||||||
|
@ -64,8 +64,8 @@ public class DynamicDataSourceAutoConfiguration implements InitializingBean {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource(List<DynamicDataSourceProvider> providers) {
|
||||||
DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource();
|
DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource(providers);
|
||||||
dataSource.setPrimary(properties.getPrimary());
|
dataSource.setPrimary(properties.getPrimary());
|
||||||
dataSource.setStrict(properties.getStrict());
|
dataSource.setStrict(properties.getStrict());
|
||||||
dataSource.setStrategy(properties.getStrategy());
|
dataSource.setStrategy(properties.getStrategy());
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.baomidou.dynamic.datasource.spring.boot.autoconfigure;
|
package com.baomidou.dynamic.datasource.spring.boot.autoconfigure;
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||||
|
import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
@ -64,8 +65,8 @@ public class DynamicDataSourceAutoConfiguration implements InitializingBean {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource(List<DynamicDataSourceProvider> providers) {
|
||||||
DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource();
|
DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource(providers);
|
||||||
dataSource.setPrimary(properties.getPrimary());
|
dataSource.setPrimary(properties.getPrimary());
|
||||||
dataSource.setStrict(properties.getStrict());
|
dataSource.setStrict(properties.getStrict());
|
||||||
dataSource.setStrategy(properties.getStrategy());
|
dataSource.setStrategy(properties.getStrategy());
|
||||||
|
@ -29,7 +29,7 @@ import lombok.Setter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Component
|
||||||
public class DynamicRoutingDataSource extends AbstractRoutingDataSource implements InitializingBean, DisposableBean {
|
public class DynamicRoutingDataSource extends AbstractRoutingDataSource implements InitializingBean, DisposableBean {
|
||||||
|
|
||||||
private static final String UNDERLINE = "_";
|
private static final String UNDERLINE = "_";
|
||||||
@ -59,8 +60,7 @@ public class DynamicRoutingDataSource extends AbstractRoutingDataSource implemen
|
|||||||
* 分组数据库
|
* 分组数据库
|
||||||
*/
|
*/
|
||||||
private final Map<String, GroupDataSource> groupDataSources = new ConcurrentHashMap<>();
|
private final Map<String, GroupDataSource> groupDataSources = new ConcurrentHashMap<>();
|
||||||
@Autowired
|
private final List<DynamicDataSourceProvider> providers;
|
||||||
private List<DynamicDataSourceProvider> providers;
|
|
||||||
@Setter
|
@Setter
|
||||||
private Class<? extends DynamicDataSourceStrategy> strategy = LoadBalanceDynamicDataSourceStrategy.class;
|
private Class<? extends DynamicDataSourceStrategy> strategy = LoadBalanceDynamicDataSourceStrategy.class;
|
||||||
@Setter
|
@Setter
|
||||||
@ -72,6 +72,10 @@ public class DynamicRoutingDataSource extends AbstractRoutingDataSource implemen
|
|||||||
@Setter
|
@Setter
|
||||||
private Boolean seata = false;
|
private Boolean seata = false;
|
||||||
|
|
||||||
|
public DynamicRoutingDataSource(List<DynamicDataSourceProvider> providers) {
|
||||||
|
this.providers = providers;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getPrimary() {
|
protected String getPrimary() {
|
||||||
return primary;
|
return primary;
|
||||||
@ -207,7 +211,7 @@ public class DynamicRoutingDataSource extends AbstractRoutingDataSource implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() {
|
||||||
log.info("dynamic-datasource start closing ....");
|
log.info("dynamic-datasource start closing ....");
|
||||||
for (Map.Entry<String, DataSource> item : dataSourceMap.entrySet()) {
|
for (Map.Entry<String, DataSource> item : dataSourceMap.entrySet()) {
|
||||||
closeDataSource(item.getKey(), item.getValue());
|
closeDataSource(item.getKey(), item.getValue());
|
||||||
@ -216,7 +220,7 @@ public class DynamicRoutingDataSource extends AbstractRoutingDataSource implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() {
|
||||||
// 检查开启了配置但没有相关依赖
|
// 检查开启了配置但没有相关依赖
|
||||||
checkEnv();
|
checkEnv();
|
||||||
// 添加并分组数据源
|
// 添加并分组数据源
|
||||||
|
13
pom.xml
13
pom.xml
@ -378,9 +378,9 @@
|
|||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<includes>
|
||||||
<exclude>com.baomidou.dynamic.datasource.fixture.v1.**</exclude>
|
<exclude>com.baomidou.dynamic.datasource.fixture.v3.**</exclude>
|
||||||
</excludes>
|
</includes>
|
||||||
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
|
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -429,13 +429,6 @@
|
|||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>nativeTestInSpringBoot</id>
|
<id>nativeTestInSpringBoot</id>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.platform</groupId>
|
|
||||||
<artifactId>junit-platform-launcher</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user