Spring Boot中yml配置文件Map集合注入及使用方式

yml配置文件

maps: "{key1: 'value1', key2: 'value2'}"

java中

@Value("#{${maps}}")  
private LinkedHashMap maps;

 我这里之所以用LinkedHashMap类型 是因为我想要是有序的 可以根据自己的来




thymeleaf遍历
<select class="form-control" name="maps" >
    <option th:each="item,m:${map}" th:value="${m.current.key}"  th:text="${m.current.value}" required></option>
</select>





-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------ (蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)
原文地址:https://www.cnblogs.com/pxblog/p/14747964.html