mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-04-26 12:29:37 +08:00
update 调整dubbo自定义负载均衡配置注入 使用spring自动注入
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.common.loadbalance.config;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
/**
|
||||
* dubbo自定义负载均衡配置注入
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class CustomEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
System.setProperty("dubbo.consumer.loadbalance", "customDubboLoadBalancer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.ruoyi.common.loadbalance.config;
|
||||
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* 自定义负载均衡自动配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@PropertySource(value = "classpath:loadbalance.properties", encoding = "UTF-8")
|
||||
@LoadBalancerClients(defaultConfiguration = CustomLoadBalanceClientConfiguration.class)
|
||||
public class CustomLoadBalanceAutoConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user