spring cloud discovery bootstrap first 非对称加密坑

本文涉及的产品
密钥管理服务KMS,1000个密钥,100个凭据,1个月
简介: 2017-04-16 00:18:17.613 INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [ main] s.
2017-04-16 00:18:17.613  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5b799640: startup date [Sun Apr 16 00:18:17 CST 2017]; root of context hierarchy
2017-04-16 00:18:17.877  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-04-16 00:18:17.912  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$51a6ef79] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-04-16 00:18:18.349  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2017-04-16 00:18:18.420  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2017-04-16 00:18:18.674  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2017-04-16 00:18:18.674  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2017-04-16 00:18:18.744  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2017-04-16 00:18:18.745  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2017-04-16 00:18:18.894  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-04-16 00:18:18.897  WARN [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Invalid eureka server URI: http://${eureka.instance.hostname}:${eureka.server.port}/eureka/; removing from the server pool
2017-04-16 00:18:18.897 ERROR [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Cannot resolve to any endpoints from provided configuration: {defaultZone=[http://${eureka.instance.hostname}:${eureka.server.port}/eureka/]}
2017-04-16 00:18:19.009 ERROR [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] c.n.d.s.transport.EurekaHttpClients      : Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info
2017-04-16 00:18:19.021  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2017-04-16 00:18:19.022  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2017-04-16 00:18:19.022  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2017-04-16 00:18:19.022  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2017-04-16 00:18:19.022  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2017-04-16 00:18:19.022  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2017-04-16 00:18:19.023  INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2017-04-16 00:18:19.027 ERROR [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [           main] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_WATER-CLOUD-PROVIDER-UAC/DESKTOP-R9436U1:water-cloud-provider-uac - was unable to refresh its cache! status = There is no known eureka server; cluster server list is empty

com.netflix.discovery.shared.transport.TransportException: There is no known eureka server; cluster server list is empty
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:107)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137)
    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
    at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1013)
    at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:927)
    at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:408)
    at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:266)
    at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:262)
    at org.springframework.cloud.netflix.eureka.CloudEurekaClient.<init>(CloudEurekaClient.java:60)
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$EurekaClientConfiguration.eurekaClient(EurekaClientAutoConfiguration.java:195)
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$EurekaClientConfiguration$$EnhancerBySpringCGLIB$$b54d3e79.CGLIB$eurekaClient$0(<generated>)
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$EurekaClientConfiguration$$EnhancerBySpringCGLIB$$b54d3e79$$FastClassBySpringCGLIB$$5f1fad18.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$EurekaClientConfiguration$$EnhancerBySpringCGLIB$$b54d3e79.eurekaClient(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:175)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
    at com.liuzm.cloud.water.provider.WaterCloudProviderUacApplication.main(WaterCloudProviderUacApplication.java:12)

说一下原因,占位符本身并没有问题。
问题在于eureka这里用了占位符。试想一下,现在是要先连上eureka,然后才能知道注册到eureka的config server的service-id而现在你都没有连上config server,试问要如何知道eureka那一行的占位符的值是什么呢?

  1. 把config server注册到eureka server上这种场景,叫discovery bootstrap first

  2. 直接配置config server的地址,叫config bootstrap first

    这里写图片描述

http://cloud.spring.io/spring-cloud-static/Dalston.RELEASE/#config-first-bootstrap

目录
相关文章
|
4月前
|
安全 Java 数据安全/隐私保护
Spring Boot中的数据加密与解密
Spring Boot中的数据加密与解密
|
8天前
|
存储 安全 Java
|
4月前
|
编解码 安全 Java
如何在Spring Boot中实现数据加密
如何在Spring Boot中实现数据加密
|
4月前
|
存储 安全 Java
Spring Boot中的配置文件加密
Spring Boot中的配置文件加密
|
5月前
|
算法 Java 数据安全/隐私保护
使用 Spring Boot 进行加密和解密:SecretKeySpec 和 Cipher
【6月更文挑战第7天】在现代软件开发中,数据加密和解密是保护敏感信息的重要手段。本文将介绍如何在 Spring Boot 项目中使用 Java 的 SecretKeySpec 和 Cipher 类来实现对称加密和解密。
806 1
|
5月前
|
安全 Java 数据安全/隐私保护
Spring Boot中的数据加密与解密
Spring Boot中的数据加密与解密
|
6月前
|
存储 安全 Java
Spring Security的密码加密和校验
本文介绍了Spring Security中密码的加密和校验。首先,在`SecurityConfig`配置类中添加了两个Bean,一个是`PasswordEncoder`的无操作实例,用于明文密码校验,另一个是`UserDetailsService`,用于创建内存中的用户信息。接着,文章对比了对称加密、非对称加密和摘要加密三种加密方式,并重点讲解了BCrypt摘要加密的特性,强调其安全性高于MD5。最后,通过代码示例展示了如何使用BCryptPasswordEncoder改造权限密码加密,确保密码的安全存储和校验。
275 6
|
6月前
|
安全 Java 数据库
Spring Security加密解密
Spring Security加密解密
225 0
|
6月前
|
算法 Java Maven
Spring Boot项目Jar包加密基本概念
Jar包加密是一种将Spring Boot项目的Jar包进行加密的技术,以保护项目中的代码和资源不被未授权访问和篡改。通过Jar包加密,可以将Jar包中的所有文件转换成加密的格式,只有拥有正确密钥的客户端才能解密和访问这些文件。
763 0
|
6月前
|
XML Java API
Spring Boot中使用集成swagger-bootstrap-ui
Spring Boot中使用集成swagger-bootstrap-ui
137 0