I created three microservices in spring boot3, 1 API Gateway, 1 Eureka Server and 1 config-server. Following are the configuration of all services -
- User Microservice
server:
port: ${port:9092}
spring:
datasource:
url: jdbc:mysql://localhost:3306/microservices
username: root
password: ${db_pass}
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: update
show-sql: true
application:
name: User-Service
config:
import: optional:configserver:http://localhost:9094
# import: optional:configserver:http://Config-Server
And the same kind of configuration for other two microservice (Rating & Hotel).
- Ereka-Server
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
server:
port: 8761
- Config-Server
server:
port: 9094
spring:
application:
name: Config-Server
cloud:
config:
server:
git:
uri: https://github.com/ayushdgupta/SpringBoot3-ConfigFiles-ConfigServer-Microservice
clone-on-start: true
- API-Gateway
server:
port: 9093
spring:
main:
web-application-type: reactive
application:
name: API-Gateway
cloud:
gateway:
routes:
- id: User-Service
uri: lb://User-Service
predicates:
- Path=/user/**
- id: Hotel-Service
uri: lb://Hotel-Service
predicates:
- Path=/hotel/**
- id: Rating-Service
uri: lb://Rating-Service
predicates:
- Path=/rating/**
config:
# import: optional:configserver:http://localhost:9094
import: optional:configserver:http://Config-Server
So everything is working fine when i am using url 'http://localhost:9094' for config-server but when i am using url 'http://Config-Server' then getting below exception in logs -
No active profile set, falling back to 1 default profile: "default"
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://Config-Server
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://Config-Server:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server. Will be trying the next url if available
2023-06-30T09:19:27.167+05:30 WARN 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@450298b6 uris = array<String>['http://Config-Server'], optional = true, profiles = list['default']]): I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://Config-Server
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://Config-Server:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server. Will be trying the next url if available
2023-06-30T09:19:27.167+05:30 WARN 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@56b52d52 uris = array<String>['http://Config-Server'], optional = true, profiles = list['default']]): I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://Config-Server
2023-06-30T09:19:27.167+05:30 INFO 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://Config-Server:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server. Will be trying the next url if available
2023-06-30T09:19:27.167+05:30 WARN 25332 --- [ restartedMain] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@33c83fe4 uris = array<String>['http://Config-Server'], optional = true, profiles = list['default']]): I/O error on GET request for "http://Config-Server/User-Service/default": Config-Server
2023-06-30T09:19:27.169+05:30 INFO 25332 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-06-30T09:19:27.170+05:30 INFO 25332 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
My question in local everything is working fine with localhost URL but when i'll deploy my application to any cloud then how my application will work because in cloud IP Address will not be fix it'll change according to my understanding, so how can i provide any generalised URL for config-server?
Try to generalize config-server url but getting exception in logs. All my services are registered with Eureka.