Commit a5035bdb authored by liaozan's avatar liaozan 🏀

Update dubbo configuration

parent 92510580
package com.schbrain.framework.autoconfigure.dubbo.listener;
import com.alibaba.fastjson2.JSONFactory;
import org.apache.dubbo.config.ConfigCenterConfig;
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.config.spring.context.event.DubboConfigInitEvent;
......@@ -28,6 +29,9 @@ class DubboConfigInitEventListener implements ApplicationListener<DubboConfigIni
@Override
public void onApplicationEvent(DubboConfigInitEvent event) {
if (event.getApplicationContext() == applicationContext) {
JSONFactory.setUseJacksonAnnotation(false);
System.setProperty("dubbo.hessian.allowNonSerializable", Boolean.TRUE.toString());
ApplicationModel applicationModel = DubboBeanUtils.getApplicationModel(applicationContext);
ConfigManager configManager = applicationModel.getApplicationConfigManager();
configManager.addConfigCenter(buildConfigCenterConfig());
......@@ -46,4 +50,4 @@ class DubboConfigInitEventListener implements ApplicationListener<DubboConfigIni
return configCenterConfig;
}
}
\ No newline at end of file
}
package com.schbrain.framework.autoconfigure.dubbo.listener;
import com.alibaba.fastjson2.JSONFactory;
import com.schbrain.common.util.ApplicationName;
import com.schbrain.common.util.properties.OrderedMapPropertySource;
import com.schbrain.framework.autoconfigure.apollo.event.ConfigLoadedEvent;
......@@ -35,11 +34,10 @@ public class DubboConfigLoadedEventListener extends GenericConfigLoadedEventList
@Override
protected void onConfigLoaded(ConfigLoadedEvent event, DubboProperties properties) {
event.getSpringApplication().addInitializers(this);
setRequiredProperties(event.getEnvironment(), event.getSpringApplication(), event.getPropertySource());
JSONFactory.setUseJacksonAnnotation(false);
addRequiredProperties(event.getEnvironment(), event.getSpringApplication(), event.getPropertySource());
}
private void setRequiredProperties(ConfigurableEnvironment environment, SpringApplication application, OrderedMapPropertySource propertySource) {
private void addRequiredProperties(ConfigurableEnvironment environment, SpringApplication application, OrderedMapPropertySource propertySource) {
if (!propertySource.containsProperty(DUBBO_SCAN_BASE_PACKAGES)) {
propertySource.addProperty(DUBBO_SCAN_BASE_PACKAGES, getBasePackage(application));
}
......@@ -52,4 +50,4 @@ public class DubboConfigLoadedEventListener extends GenericConfigLoadedEventList
return application.getMainApplicationClass().getPackage().getName();
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment