我试图从我的Spring Cloud Config Server获取一些属性文件,而不使用spring boot . 我是通过创建这个类来完成的:

@Configuration
@PropertySource({"http://localhost:8081/application-default.properties", "http://localhost:8081/application-dev.properties"})

public class AppConfiguration {

@Bean
public static PropertySourcesPlaceholderConfigurer pspc(){
    return new PropertySourcesPlaceholderConfigurer();
    }
}

然后我可以从上下文的环境中获取属性 . 这是应该的 . 问题是我现在已经在我的服务器上添加了基本身份验证,所以很自然我现在收到此错误:

java.net.ConnectException: Connection refused: connect

我的问题是如何在我的服务器启用基本身份验证时获取属性文件?谢谢 .