master
Giorno 3 years ago
parent 113dc70ba0
commit 5445742a7e

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

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

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

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

Loading…
Cancel
Save