摘要:這裏介紹一下springBoot中的兩種文件配置方式中數組的使用,也就是集合。
以下是我springBoot中使用的 application.properties 文件
其實很好理解,我的configs是一個集合,configs[0].appid代表我配置的第一個對象中的appid的值
miniapp.configs[0].appid = 111111
miniapp.configs[0].secret= 222222
miniapp.configs[0].token = 333333
miniapp.configs[0].aesKey = 444444
miniapp.configs[0].msgDataFormat = JSON
這個是使用application.yml的方式,因爲YAML 本身支持 list 類型,所以可以在 application.yml 文件中添加:
yml如果配置普通字符串
miniapp:
configs:
- appid:111111
- appid:222222
- appid:333333
數組和map等寫法參考:https://suxiexingchen.github.io/2019/11/08/27/