Zuul2.1 sample程序启动篇

Zuul2.1的官方sample程序需要AWS环境才能启动,因为其依赖Eureka的数据中心。通过分析源码发现,可以使用MyOwn数据中心类型来解决这一问题。通过调整配置,使得在没有AWS环境的情况下,sample程序也能成功启动并正常运行。
摘要由CSDN通过智能技术生成

Zuul2.1 sample程序启动篇

问题

不使用AWS环境,Zuul2.1的sample程序是无法启动的。报错如下:

WARN  com.netflix.discovery.internal.util.Archaius1Utils [main] Cannot find the properties specified : eureka-client. This may be okay if there are other environment specific properties or the configuration is installed with a different mechanism.
WARN  com.netflix.discovery.internal.util.Archaius1Utils [main] Cannot find the properties specified : eureka-client. This may be okay if there are other environment specific properties or the configuration is installed with a different mechanism.
WARN  com.netflix.appinfo.AmazonInfo$Builder [main] Skipping the rest of AmazonInfo init as we were not able to load instanceId after the configured number of retries: 3, per fail fast configuration: true
INFO  com.netflix.appinfo.RefreshableAmazonInfoProvider [main] Datacenter is: Amazon

分析一下源码,eureka支持三种数据中心:Netflix、Amazon和MyOwn。
BaseServerStartup类使用google inject实现依赖注入。
BaseServerStartup依赖ServerStatusManager和ApplicationInfoManager。

    @Inject
    public ServerStatusManager(ApplicationInfoManager applicationInfoManager, DiscoveryClient discoveryClient) {
    
    }

    @Inject
    public ApplicationInfoManager(EurekaInstanceConfig config, InstanceInfo instanceInfo, OptionalArgs optionalArgs) {
    
    }

ApplicationInfoManager依赖EurekaInstanceConfig接口的实现。

@ImplementedBy(CloudInstanceConfig.class)
public interface EurekaInstanceConfig {
     

}

@Singleton
@ProvidedBy(CloudInstanceConfigProvider.class)
public class CloudInstanceConfig extends PropertiesInstanceConfig implements RefreshableInstanceConfig {
    
    public CloudInstanceConfig(String namespace) {
    
        this(namespace,
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值