update 调整dubbo自定义负载均衡配置注入 使用spring自动注入
parent
529e025494
commit
6678ec6b7b
@ -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,2 +1,4 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.ruoyi.common.loadbalance.config.CustomLoadBalanceAutoConfiguration
|
com.ruoyi.common.loadbalance.config.CustomLoadBalanceAutoConfiguration
|
||||||
|
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||||
|
com.ruoyi.common.loadbalance.config.CustomEnvironmentPostProcessor
|
||||||
|
@ -1 +0,0 @@
|
|||||||
dubbo.consumer.loadbalance=customDubboLoadBalancer
|
|
Loading…
Reference in New Issue