diff --git a/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/pom.xml b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/pom.xml
index cbac1412..6bec3461 100644
--- a/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/pom.xml
+++ b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/pom.xml
@@ -21,7 +21,11 @@
spring-cloud-starter-alibaba-nacos-config
1.5.1.RELEASE
-
+
+
+
+
+
org.springframework.boot
spring-boot-starter
diff --git a/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/application.properties b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/application.properties
new file mode 100644
index 00000000..2e8be029
--- /dev/null
+++ b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/application.properties
@@ -0,0 +1,66 @@
+#debug=true
+server.port=8089
+server.servlet.context-path=/example
+
+management.security.enabled=false
+management.context-path=/actuator
+
+spring.profiles.active=dev
+spring.application.name=hippo4j-config-nacos-spring-boot-1x-starter-example
+
+## nacos spring-boot
+nacos.config.server-addr=127.0.0.1:8848
+nacos.config.ext-config[0].data-id=hippo4j-nacos.yaml
+nacos.config.ext-config[0].group=DEFAULT_GROUP
+nacos.config.ext-config[0].auto-refresh=true
+
+spring.dynamic.thread-pool.enable=true
+spring.dynamic.thread-pool.banner=true
+spring.dynamic.thread-pool.check-state-interval=5
+spring.dynamic.thread-pool.monitor.enable=true
+spring.dynamic.thread-pool.monitor.collect-types=micrometer
+spring.dynamic.thread-pool.monitor.thread-pool-types=dynamic,web
+spring.dynamic.thread-pool.monitor.initial-delay=10000
+spring.dynamic.thread-pool.monitor.collect-interval=5000
+
+spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT
+spring.dynamic.thread-pool.notify-platforms[0].token=ac0426a5-c712-474c-9bff-72b8b8f5caff
+spring.dynamic.thread-pool.notify-platforms[1].platform=DING
+spring.dynamic.thread-pool.notify-platforms[1].token=56417ebba6a27ca352f0de77a2ae9da66d01f39610b5ee8a6033c60ef9071c55
+spring.dynamic.thread-pool.notify-platforms[2].platform=LARK
+spring.dynamic.thread-pool.notify-platforms[2].token=2cbf2808-3839-4c26-a04d-fd201dd51f9e
+
+spring.dynamic.thread-pool.nacos.data-id=hippo4j-nacos.yaml
+spring.dynamic.thread-pool.nacos.group=DEFAULT_GROUP
+spring.dynamic.thread-pool.config-file-type=yaml
+
+spring.dynamic.thread-pool.executors[0].thread-pool-id=message-consume
+spring.dynamic.thread-pool.executors[0].thread-name-prefix=message-consume
+spring.dynamic.thread-pool.executors[0].core-pool-size=2
+spring.dynamic.thread-pool.executors[0].maximum-pool-size=4
+spring.dynamic.thread-pool.executors[0].queue-capacity=1024
+spring.dynamic.thread-pool.executors[0].blocking-queue=ResizableCapacityLinkedBlockingQueue
+spring.dynamic.thread-pool.executors[0].execute-time-out=800
+spring.dynamic.thread-pool.executors[0].rejected-handler=AbortPolicy
+spring.dynamic.thread-pool.executors[0].keep-alive-time=6691
+spring.dynamic.thread-pool.executors[0].allow-core-thread-time-out=true
+spring.dynamic.thread-pool.executors[0].alarm=true
+spring.dynamic.thread-pool.executors[0].active-alarm=80
+spring.dynamic.thread-pool.executors[0].capacity-alarm=80
+spring.dynamic.thread-pool.executors[0].notify.interval=8
+spring.dynamic.thread-pool.executors[0].notify.receives=chen.ma
+spring.dynamic.thread-pool.executors[1].thread-pool-id=message-produce
+spring.dynamic.thread-pool.executors[1].thread-name-prefix=message-produce
+spring.dynamic.thread-pool.executors[1].core-pool-size=2
+spring.dynamic.thread-pool.executors[1].maximum-pool-size=4
+spring.dynamic.thread-pool.executors[1].queue-capacity=1024
+spring.dynamic.thread-pool.executors[1].blocking-queue=ResizableCapacityLinkedBlockingQueue
+spring.dynamic.thread-pool.executors[1].execute-time-out=800
+spring.dynamic.thread-pool.executors[1].rejected-handler=AbortPolicy
+spring.dynamic.thread-pool.executors[1].keep-alive-time=6691
+spring.dynamic.thread-pool.executors[1].allow-core-thread-time-out=true
+spring.dynamic.thread-pool.executors[1].alarm=true
+spring.dynamic.thread-pool.executors[1].active-alarm=80
+spring.dynamic.thread-pool.executors[1].capacity-alarm=80
+spring.dynamic.thread-pool.executors[1].notify.interval=8
+spring.dynamic.thread-pool.executors[1].notify.receives=chen.ma
diff --git a/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/bootstrap.properties b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/bootstrap.properties
index 4ee562fc..38a8364b 100644
--- a/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/bootstrap.properties
+++ b/hippo4j-example/hippo4j-config-nacos-spring-boot-1x-starter-example/src/main/resources/bootstrap.properties
@@ -8,6 +8,7 @@ management.context-path=/actuator
spring.profiles.active=dev
spring.application.name=hippo4j-config-nacos-spring-boot-1x-starter-example
+# nacos spring-cloud
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.ext-config[0].data-id=hippo4j-nacos.yaml
spring.cloud.nacos.config.ext-config[0].group=DEFAULT_GROUP
diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/ConfigHandlerConfiguration.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/ConfigHandlerConfiguration.java
index 4c1dac08..1deac720 100644
--- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/ConfigHandlerConfiguration.java
+++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/ConfigHandlerConfiguration.java
@@ -17,15 +17,21 @@
package cn.hippo4j.config.springboot.starter.config;
-import cn.hippo4j.config.springboot.starter.refresher.*;
-import com.alibaba.cloud.nacos.NacosConfigManager;
+import cn.hippo4j.config.springboot.starter.refresher.ApolloRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.BootstrapConfigPropertiesBinderAdapt;
+import cn.hippo4j.config.springboot.starter.refresher.ConsulRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.DefaultBootstrapConfigPropertiesBinderAdapt;
+import cn.hippo4j.config.springboot.starter.refresher.EtcdRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.NacosCloudRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.NacosRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.PolarisRefresherHandler;
+import cn.hippo4j.config.springboot.starter.refresher.ZookeeperRefresherHandler;
import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.nacos.api.config.ConfigService;
import com.tencent.polaris.configuration.api.core.ConfigFileService;
import io.etcd.jetcd.Client;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
@@ -42,6 +48,8 @@ public class ConfigHandlerConfiguration {
private static final String NACOS_CONFIG_MANAGER_KEY = "com.alibaba.cloud.nacos.NacosConfigManager";
+ private static final String NACOS_INJECTED_BEAN_NAME = "com.alibaba.nacos.spring.beans.factory.annotation.AnnotationNacosInjectedBeanPostProcessor";
+
private static final String NACOS_DATA_ID_KEY = "nacos.data-id";
private static final String APOLLO_NAMESPACE_KEY = "apollo.namespace";
@@ -61,18 +69,18 @@ public class ConfigHandlerConfiguration {
}
@RequiredArgsConstructor
- @ConditionalOnClass(ConfigService.class)
+ @ConditionalOnClass(value = ConfigService.class, name = NACOS_INJECTED_BEAN_NAME)
@ConditionalOnMissingClass(NACOS_CONFIG_MANAGER_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacos {
@Bean
- public NacosRefresherHandler nacosRefresherHandler(NacosConfigProperties nacosConfigProperties) {
- return new NacosRefresherHandler(nacosConfigProperties);
+ public NacosRefresherHandler nacosRefresherHandler() {
+ return new NacosRefresherHandler();
}
}
- @ConditionalOnClass(NacosConfigManager.class)
+ @ConditionalOnClass(NacosConfigProperties.class)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacosCloud {
diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosCloudRefresherHandler.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosCloudRefresherHandler.java
index 445f3cd2..47aae1ed 100644
--- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosCloudRefresherHandler.java
+++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosCloudRefresherHandler.java
@@ -18,7 +18,8 @@
package cn.hippo4j.config.springboot.starter.refresher;
import cn.hippo4j.common.config.ApplicationContextHolder;
-import com.alibaba.cloud.nacos.NacosConfigManager;
+import com.alibaba.cloud.nacos.NacosConfigProperties;
+import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.SneakyThrows;
@@ -37,17 +38,17 @@ public class NacosCloudRefresherHandler extends AbstractConfigThreadPoolDynamicR
static final String GROUP = "group";
- private final NacosConfigManager nacosConfigManager;
+ private final ConfigService configService;
public NacosCloudRefresherHandler() {
- nacosConfigManager = ApplicationContextHolder.getBean(NacosConfigManager.class);
+ configService = ApplicationContextHolder.getBean(NacosConfigProperties.class).configServiceInstance();
}
@SneakyThrows(NacosException.class)
@Override
public void initRegisterListener() {
Map nacosConfig = bootstrapConfigProperties.getNacos();
- nacosConfigManager.getConfigService().addListener(nacosConfig.get(DATA_ID),
+ configService.addListener(nacosConfig.get(DATA_ID),
nacosConfig.get(GROUP), new Listener() {
@Override
diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosRefresherHandler.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosRefresherHandler.java
index 896d8ad8..0b795b23 100644
--- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosRefresherHandler.java
+++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/NacosRefresherHandler.java
@@ -17,7 +17,6 @@
package cn.hippo4j.config.springboot.starter.refresher;
-import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
@@ -41,8 +40,8 @@ public class NacosRefresherHandler extends AbstractConfigThreadPoolDynamicRefres
@NacosInjected
private ConfigService configService;
- public NacosRefresherHandler(NacosConfigProperties nacosConfigProperties) {
- this.configService = nacosConfigProperties.configServiceInstance();
+ public NacosRefresherHandler() {
+ super();
}
@SneakyThrows(NacosException.class)
diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java
index 7689f35b..d59c8912 100644
--- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java
+++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java
@@ -17,9 +17,11 @@
package cn.hippo4j.springboot.starter.monitor.local.log;
+import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.monitor.local.log.AdapterThreadPoolLocalLogMonitorHandler;
import cn.hippo4j.monitor.local.log.DynamicThreadPoolLocalLogMonitorHandler;
import cn.hippo4j.monitor.local.log.WebThreadPoolLocalLogMonitorHandler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -38,6 +40,7 @@ public class LocalLogMonitorAutoConfiguration {
}
@Bean
+ @ConditionalOnBean(WebThreadPoolService.class)
@ConditionalOnExpression("'${spring.dynamic.thread-pool.monitor.thread-pool-types:}'.contains('web')")
public WebThreadPoolLocalLogMonitorHandler webThreadPoolLocalLogMonitorHandler() {
return new WebThreadPoolLocalLogMonitorHandler();
diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java
index 130ad862..d523575f 100644
--- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java
+++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java
@@ -17,9 +17,11 @@
package cn.hippo4j.springboot.starter.monitor.micrometer;
+import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.monitor.micrometer.AdapterThreadPoolMicrometerMonitorHandler;
import cn.hippo4j.monitor.micrometer.DynamicThreadPoolMicrometerMonitorHandler;
import cn.hippo4j.monitor.micrometer.WebThreadPoolMicrometerMonitorHandler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -38,6 +40,7 @@ public class MicrometerMonitorAutoConfiguration {
}
@Bean
+ @ConditionalOnBean(WebThreadPoolService.class)
@ConditionalOnExpression("'${spring.dynamic.thread-pool.monitor.thread-pool-types:}'.contains('web')")
public WebThreadPoolMicrometerMonitorHandler webThreadPoolMicrometerMonitorHandler() {
return new WebThreadPoolMicrometerMonitorHandler();