{"id":906,"date":"2023-03-11T16:52:58","date_gmt":"2023-03-11T08:52:58","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=906"},"modified":"2023-04-29T15:51:46","modified_gmt":"2023-04-29T07:51:46","slug":"spring-boot-configuration-file-yml-custom-array-or-list-collection","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/11\/spring-boot-configuration-file-yml-custom-array-or-list-collection\/","title":{"rendered":"Spring Boot\u914d\u7f6e\u6587\u4ef6yml\u81ea\u5b9a\u4e49\u6570\u7ec4\u6216List\u96c6\u5408"},"content":{"rendered":"<h3>\u81ea\u5b9a\u4e49List\u96c6\u5408<\/h3>\n<p>\u9996\u5148\u5728<code>application.yml<\/code>\u6587\u4ef6\u4e2d\u914d\u7f6e<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-yml\">email:\n  mailList[0]:\n    username: xxx@xxx.com\n    password: axxx\n  mailList[1]:\n    username: xxx@xxx.com\n    password: bxxx<\/code><\/pre>\n<p>\u7136\u540e\u914d\u7f6e\u63a5\u53d7\u7c7b<\/p>\n<pre><code class=\"language-java\">@Data\n@Configuration\n@ConfigurationProperties(&quot;email&quot;)\npublic class EmailConfig {\n    private List&lt;MailInfo&gt; mailList;  \/\/\u6ce8\u610f\u5b57\u6bb5\u540d\u79f0\u4fdd\u6301\u4e00\u81f4\n}<\/code><\/pre>\n<p>MailInfo\u7c7b\u7684\u5185\u5bb9\u662f<\/p>\n<pre><code class=\"language-java\">@Data\npublic class MailInfo {\n    private String username;\n    private String password;\n}<\/code><\/pre>\n<h3>\u81ea\u5b9a\u4e49\u6570\u7ec4<\/h3>\n<p>\u9996\u5148\u5728application.yml\u6587\u4ef6\u4e2d\u914d\u7f6e<\/p>\n<pre><code class=\"language-yml\">path:\n  ignored-token-path: \/base\/xx\/login, \/home\/**\n  ignored-role-path: \/base\/xx\/logout, \/base\/xx\/menu<\/code><\/pre>\n<p>\u7136\u548c\u914d\u7f6e\u63a5\u53d7\u7c7b<\/p>\n<pre><code class=\"language-java\">@Data\n@Configuration\n@ConfigurationProperties(&quot;path&quot;)\npublic class PathConfig {\n    private String[] ignoredTokenPath;\n    private String[] ignoredRolePath;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5b9a\u4e49List\u96c6\u5408 \u9996\u5148\u5728application.yml\u6587\u4ef6\u4e2d\u914d\u7f6e email: mailList[0]: u [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-906","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=906"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/906\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}