首页 > 解决方案 > Spring boot @Configurationproperties 大 yaml 文件 - 嵌套映射

问题描述

我正在运行一个 Spring Boot 应用程序并有一个大型 application.yml 文件,该文件具有复杂结构(嵌套映射)的属性,我正在尝试使用 @Configurationproperties 进行绑定。我可以在文件较小时绑定它,但随着文件大小的增长,加载需要很长时间并增加启动时间。Yaml 的结构:

a:
  b:
    - map1: 
       '3000':
        map2:
           '3000': 'true'
           '3010': 'true'
           '4000': 'true'
           '4300': 'true'
           '3300': 'true'
           '3400': 'true'
           '3700': 'true'
           '4600': 'true'
           '4700': 'true'
       '3010':
        map2:
           '3000': 'true'
           '3010': 'true'
           '4000': 'true'
           '4300': 'true'
           '3300': 'true'
           '3400': 'true'
           '3700': 'true'
           '4600': 'true'
           '4700': 'true'

我想减少加载时间,想知道是否有办法延迟加载嵌套地图。即仅在请求某些内容时才加载地图?

标签: springspring-boot

解决方案


推荐阅读