首页 > 解决方案 > 如何使用嵌套列表作为环境变量

问题描述

我有这个yml文件:

spring:
  cloud:
    gateway:
      routes:
        - id: microservice1
          uri: http://m1:8082

          predicates:
            - Path=/m1/**
            - Method=GET,POST,DELETE,PUT,OPTIONS

        - id: microservice2
          uri: http://m2:8083

          predicates:
            - Path=/m2/**
            - Method=GET,POST,DELETE,PUT,OPTIONS

我想翻译成一个.env文件。

我怎么能得到那个?,我已经试过了(我添加了新的行以更容易阅读,在我的本地都是一行):

spring.cloud.gateway.routes=[
                              id=microservice1,
                              uri=http://m1:8082,
                              predicates=[
                                          Path=/m1/**,
                                          Method=GET,POST,DELETE,PUT,OPTIONS]
                              ],
                              id=microservice2,
                              uri=http://m2:8083,
                              predicates=[
                                          Path=/m2/**,
                                          Method=GET,POST,DELETE,PUT,OPTIONS]
                              ],

但它会引发错误:

Illegal character in path at index 0: [Path=/m1/**

标签: environment-variables

解决方案


推荐阅读