Config Related Code in Spring Cloud Netflix - Eureka
Server Dependency
Your Eureka project -> spring-cloud-starter-eureka-server -> spring-cloud-starter-netflix-eureka-server, which depends on
- spring-cloud-starter
- spring-cloud-netflix-eureka-server
- spring-cloud-starter-netflix-archaius
- spring-cloud-starter-netflix-ribbon
- com.netflix.ribbon.ribbon-eureka
Note that there is no concrete code until spring-cloud-netflix-eureka-server
During Server Bootstrap
- Look for spring.profiles.active
- Look for spring.profiles.default
- Look for eureka.datacenter
- Look for eureka.environment
- Check if applicationInfoManager’s dataCenterInfo is AWS/Amazon, if so, start the AWS binder. Note that it defaults to EIP binding strategy
- For other settings, check ServerConfigBean, which is populated via reflection/injection. AVOID VANILLA EUREKA CONFIG PATH FROM NETFLIX DOC!
Spring Cloud Eureka Client Config
- Client will look for az in a region, if az is not defined, it will use “defaultZone”
- Client will look for serviceUrl.”myZone”, if it is undefined, it will look for serviceUrl.defaultZone
- serviceUrl defaults to “defaultZone” -> “http://localhost:8761/eureka”. That is why local run can do without setting default Url
- For other settings, check ClientConfigBean, which is populated via relfection/injection. AVOID VANILLA EUREKA CONFIG PATH FROM NETFLIX DOC!
Note
- In my Eureka project, application.yml and application.properties can co-exist in src/main/resources and both will be read. I use application.properties to config logger, which is logback
- Following the guide, the aws specific init is placed in the main of my eureka server. Note the example has a @Profile(“!default”) flag, i.e., you need to set spring.profiles.active to something other than “default”, either via -D arguments or application.properties