关于yml:Caused-by-orgyamlsnakeyamlscannerScannerException

呈现这个问题次要是yml文件的语法呈现了问题。yml根本语法如下: 大小写敏感冒号前面要有空格只容许应用空格缩进,示意层级关系雷同层级的元素须要左侧对齐# 示意正文,从这个字符始终到行尾我遇到这个谬误是因为缩进问题:第6行的uri应该与id左对齐,uri上面几句话也要相应左移: spring: cloud: gateway: routes: - id: product_route uri: lb://shoppingmall-product predicates: - Path=/api/product/** filters: - RewritePath=/api/(?<segment>.*),/$\{segment} - id: admin_route uri: lb://renren-fast predicates: - Path=/api/** filters: - RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}批改之后: spring: cloud: gateway: routes: - id: product_route uri: lb://shoppingmall-product predicates: - Path=/api/product/** filters: - RewritePath=/api/(?<segment>.*),/$\{segment} - id: admin_route uri: lb://renren-fast predicates: - Path=/api/** filters: - RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}这样就不会报错了。

June 3, 2021 · 1 min · jiezi

springboot-使用yml格式进行配置的方法

一、前言springboot配置文件的格式,有两种方式,一种是properties,就是application.properties,另一种就是yml格式,application.yml两种方式是差不多的,默认是properties,yml格式看起来会很有层次感如图,下边两种形式的效果是相同的:二、application.yml注意事项不同等级用冒号隔开次等级的前面是空格,不能使用制表符(tab)冒号之后如果有值,那么冒号和值之间至少有一个空格(实际上紧贴着也不影响)要么用application.properties,要么用application.yml,不要同时存在,否则的话yml中书写的时候,idea编辑器可能没有补全功能了三、参考链接http://how2j.cn/k/springboot/...

July 9, 2019 · 1 min · jiezi