修复nacos,etcd由于SpringAware取不到bean会报错的问题

This commit is contained in:
everywhere.z
2022-10-25 18:01:13 +08:00
parent d40198dc2e
commit a6094a0ce5
3 changed files with 7 additions and 3 deletions

View File

@@ -30,7 +30,9 @@ public class EtcdParserHelper {
this.etcdParserVO = etcdParserVO;
try{
this.etcdClient = ContextAwareHolder.loadContextAware().getBean(EtcdClient.class);
try{
this.etcdClient = ContextAwareHolder.loadContextAware().getBean(EtcdClient.class);
}catch (Exception ignored){}
if (this.etcdClient == null) {
Client client = Client.builder()
.endpoints(etcdParserVO.getConnectStr().split(","))

View File

@@ -32,7 +32,9 @@ public class NacosParserHelper {
public NacosParserHelper(NacosParserVO nacosParserVO) {
this.nacosParserVO = nacosParserVO;
try{
this.configService = ContextAwareHolder.loadContextAware().getBean(NacosConfigService.class);
try{
this.configService = ContextAwareHolder.loadContextAware().getBean(NacosConfigService.class);
}catch (Exception ignored){}
if (this.configService == null){
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, nacosParserVO.getServerAddr());

View File

@@ -39,7 +39,7 @@
</scm>
<properties>
<revision>2.9.1</revision>
<revision>2.9.2</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>8</maven.compiler.source>