1、优化nacos注入ConfigService对象

2、升级apollo-client包(避免不支持JDK8以上问题)
pull/32/head
3y 2 years ago
parent 7047d92dd6
commit b73aa9c54b

@ -75,7 +75,7 @@
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client-config-data</artifactId>
<artifactId>apollo-client</artifactId>
</dependency>

@ -1,8 +1,8 @@
package com.java3y.austin.support.utils;
import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
@ -22,19 +22,14 @@ import java.util.Properties;
@Slf4j
@Component
public class NacosUtils {
@Value("${austin.nacos.server}")
private String nacosServer;
@Value("${austin.nacos.username}")
private String nacosUsername;
@Value("${austin.nacos.password}")
private String nacosPassword;
@NacosInjected
private ConfigService configService;
@Value("${austin.nacos.group}")
private String nacosGroup;
@Value("${austin.nacos.dataId}")
private String nacosDataId;
@Value("${austin.nacos.namespace}")
private String nacosNamespace;
private final Properties request = new Properties();
private final Properties properties = new Properties();
public String getProperty(String key, String defaultValue) {
@ -53,12 +48,7 @@ public class NacosUtils {
private String getContext() {
String context = null;
try {
request.put(PropertyKeyConst.SERVER_ADDR, nacosServer);
request.put(PropertyKeyConst.NAMESPACE, nacosNamespace);
request.put(PropertyKeyConst.USERNAME, nacosUsername);
request.put(PropertyKeyConst.PASSWORD, nacosPassword);
context = NacosFactory.createConfigService(request)
.getConfig(nacosDataId, nacosGroup, 5000);
context = configService.getConfig(nacosDataId, nacosGroup, 5000);
} catch (NacosException e) {
log.error("Nacos error:{}", ExceptionUtils.getStackTrace(e));
}

@ -77,12 +77,13 @@ apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml
########################################## apollo end ##########################################
########################################## nacos start ##########################################
austin.nacos.server=austin.nacos:8848
austin.nacos.username=nacos
austin.nacos.password=nacos
nacos.config.server-addr=austin.nacos:8848
nacos.config.username=nacos
nacos.config.password=nacos
nacos.config.namespace=9537c674-f3a6-4203-b286-ef0c36bfacb2
austin.nacos.dataId=austin
austin.nacos.group=DEFAULT_GROUP
austin.nacos.namespace=9537c674-f3a6-4203-b286-ef0c36bfacb2
nacos.config.enabled=${austin.nacos.enabled}
########################################## nacos end ##########################################

@ -95,8 +95,8 @@
<!--apollo-->
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client-config-data</artifactId>
<version>1.9.1</version>
<artifactId>apollo-client</artifactId>
<version>2.1.0</version>
</dependency>
<!--注解打印日志-->

Loading…
Cancel
Save