yml注入List<Map>

yml配置文件

robot:
  list:
    - name: robot1
      url: ws://ip/client
      file: http://ip/file
    - name: robot2
      url: ws://ip/client
      file: http://ip/file
    - name: robot3
      url: ws://ip/client
      file: http://ip/file

class类文件

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@ConfigurationProperties(prefix = "robot")
public class Robot {
    public static List<Map<String, String>> list;

    public static List<Map<String, String>> getList() {
        return list;
    }

    public void setList(List<Map<String, String>> list) {
        Robot.list = list;
    }
}

 

posted @ 2021-06-23 11:35  缘故为何  阅读(960)  评论(0编辑  收藏  举报