mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed 23753d7 from https://gitee.com/Suomm/mybatis-flex/pulls/73
fix: 低版本 spring-cloud 使用 bootstrap.yml 拉取不到 nacos 中多数据源配置。
This commit is contained in:
parent
96444b7028
commit
b5fa40f36a
@ -19,6 +19,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
|||||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||||
import org.springframework.context.annotation.ConditionContext;
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.env.*;
|
import org.springframework.core.env.*;
|
||||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ import java.util.Iterator;
|
|||||||
@Conditional(ConditionalOnMybatisFlexDatasource.OnMybatisFlexDataSourceCondition.class)
|
@Conditional(ConditionalOnMybatisFlexDatasource.OnMybatisFlexDataSourceCondition.class)
|
||||||
public @interface ConditionalOnMybatisFlexDatasource {
|
public @interface ConditionalOnMybatisFlexDatasource {
|
||||||
|
|
||||||
|
@Order(Ordered.HIGHEST_PRECEDENCE + 40)
|
||||||
class OnMybatisFlexDataSourceCondition extends SpringBootCondition {
|
class OnMybatisFlexDataSourceCondition extends SpringBootCondition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,8 +47,8 @@ public @interface ConditionalOnMybatisFlexDatasource {
|
|||||||
Iterator<PropertySource<?>> it = propertySources.stream().iterator();
|
Iterator<PropertySource<?>> it = propertySources.stream().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
PropertySource<?> ps = it.next();
|
PropertySource<?> ps = it.next();
|
||||||
if (ps instanceof MapPropertySource) {
|
if (ps instanceof EnumerablePropertySource) {
|
||||||
for (String propertyName : ((MapPropertySource) ps).getSource().keySet()) {
|
for (String propertyName : ((EnumerablePropertySource<?>) ps).getPropertyNames()) {
|
||||||
if (propertyName.startsWith("mybatis-flex.datasource.")) {
|
if (propertyName.startsWith("mybatis-flex.datasource.")) {
|
||||||
return ConditionOutcome.match();
|
return ConditionOutcome.match();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user