Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

springcloud api gateway properties file declaring variables

I have application.yaml in springboot app as below

spring:
  cloud:
    gateway:
      routes:
      - id: pgService
        uri: http://localhost:2005/
        predicates:
        - Path=/employee/**
      - id: inMateService
        uri: http://localhost:2006/
        predicates:
        - Path=/consumer/**

The above declared variables are with respect to spring cloud gateway

I want to declare these same variables in application.properties file. i don't want to use yaml file. please help me to achieve this Thank you

like image 510
CHETAN PATIL Avatar asked Apr 18 '26 08:04

CHETAN PATIL


1 Answers

You can define the variables as follows in your application.properties file:

spring.cloud.gateway.routes[0].id=pgService
spring.cloud.gateway.routes[0].uri=http://localhost:2005/
spring.cloud.gateway.routes[0].predicates[0]=Path=/employee/**
spring.cloud.gateway.routes[1].id=inMateService
spring.cloud.gateway.routes[1].uri=http://localhost:2006/
spring.cloud.gateway.routes[1].predicates[0]=Path=/consumer/**
like image 72
khwilo Avatar answered Apr 20 '26 23:04

khwilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!