master
Giorno 3 years ago
parent 113dc70ba0
commit 5445742a7e

@ -10,8 +10,8 @@ public interface ConfigService {
/**
*
* 1使apolloapollo
* 2apollo local.properties
* 1使apollonacos
* 2 local.properties
* @param key
* @param defaultValue
* @return

@ -5,8 +5,10 @@ import cn.hutool.setting.dialect.Props;
import com.ctrip.framework.apollo.Config;
import com.java3y.austin.support.service.ConfigService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
@ -30,12 +32,21 @@ public class ConfigServiceImpl implements ConfigService {
private Boolean enableApollo;
@Value("${apollo.bootstrap.namespaces}")
private String namespaces;
/**
* nacos
*/
@Value("${austin.nacos.enabled}")
private Boolean enableNacos;
@Resource
private ConfigurableApplicationContext configurableApplicationContext;
@Override
public String getProperty(String key, String defaultValue) {
if (enableApollo) {
Config config = com.ctrip.framework.apollo.ConfigService.getConfig(namespaces.split(StrUtil.COMMA)[0]);
return config.getProperty(key, defaultValue);
} else if (enableNacos) {
return configurableApplicationContext.getEnvironment().getProperty(key, defaultValue);
} else {
return props.getProperty(key, defaultValue);
}

@ -128,6 +128,10 @@ app.id=austin
apollo.bootstrap.enabled=${apollo.enabled}
apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml
##################### nacos #####################
austin.nacos.enabled=false
##################### httpUtils properties #####################
ok.http.connect-timeout=30
ok.http.keep-alive-duration=300

@ -212,5 +212,4 @@
</dependencyManagement>
</project>

Loading…
Cancel
Save