{"id":111465,"date":"2026-10-01T10:15:57","date_gmt":"2026-10-01T02:15:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/111465.html"},"modified":"2026-10-01T10:15:57","modified_gmt":"2026-10-01T02:15:57","slug":"springboot-%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e8%af%a6%e8%a7%a3%ef%bc%9aproperties-%e4%b8%8e-yml-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/111465.html","title":{"rendered":"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"%E2%80%8B%E7%BC%96%E8%BE%91%E4%B8%80%E3%80%81%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">\u200b\u7f16\u8f91\u4e00\u3001\u914d\u7f6e\u6587\u4ef6\u7684\u4f5c\u7528<\/p>\n<p id=\"%E4%BA%8C%E3%80%81SpringBoot%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:40px\">\u4e8c\u3001SpringBoot \u914d\u7f6e\u6587\u4ef6\u683c\u5f0f<\/p>\n<p id=\"1.%20%E5%BF%AB%E9%80%9F%E4%BF%AE%E6%94%B9%E7%AB%AF%E5%8F%A3-toc\" style=\"margin-left:80px\">1. \u5feb\u901f\u4fee\u6539\u7aef\u53e3<\/p>\n<p id=\"2.%20properties%20%E4%B8%8E%20yml%20%E5%85%B1%E5%AD%98-toc\" style=\"margin-left:80px\">2. properties \u4e0e yml \u5171\u5b58<\/p>\n<p id=\"%E4%B8%89%E3%80%81properties%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:40px\">\u4e09\u3001properties \u914d\u7f6e\u6587\u4ef6<\/p>\n<p id=\"1.%20%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%C2%A0%E8%BF%9E%E6%8E%A5%EF%BC%9A-toc\" style=\"margin-left:80px\">1. \u57fa\u672c\u8bed\u6cd5\u00a0\u8fde\u63a5&#xff1a;<\/p>\n<p id=\"2.%20%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE-toc\" style=\"margin-left:80px\">2. \u8bfb\u53d6\u914d\u7f6e<\/p>\n<p id=\"3.%20%E7%BC%BA%E7%82%B9-toc\" style=\"margin-left:80px\">3. \u7f3a\u70b9<\/p>\n<p id=\"%E5%9B%9B%E3%80%81yml%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:40px\">\u56db\u3001yml \u914d\u7f6e\u6587\u4ef6<\/p>\n<p id=\"1.%20%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95-toc\" style=\"margin-left:80px\">1. \u57fa\u672c\u8bed\u6cd5<\/p>\n<p id=\"2.%20%E9%85%8D%E7%BD%AE%E4%B8%8D%E5%90%8C%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%8F%8A%20null-toc\" style=\"margin-left:80px\">2. \u914d\u7f6e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53ca null<\/p>\n<p id=\"3.%20%E8%AF%BB%E5%8F%96%20yml%20%E9%85%8D%E7%BD%AE-toc\" style=\"margin-left:80px\">3. \u8bfb\u53d6 yml \u914d\u7f6e<\/p>\n<p id=\"4.%20%E5%8D%95%E5%8F%8C%E5%BC%95%E5%8F%B7%E7%9A%84%E5%8C%BA%E5%88%AB-toc\" style=\"margin-left:80px\">4. \u5355\u53cc\u5f15\u53f7\u7684\u533a\u522b<\/p>\n<p id=\"5.%20%E9%85%8D%E7%BD%AE%E5%AF%B9%E8%B1%A1-toc\" style=\"margin-left:80px\">5. \u914d\u7f6e\u5bf9\u8c61<\/p>\n<p id=\"6.%20%E9%85%8D%E7%BD%AE%E9%9B%86%E5%90%88%20List-toc\" style=\"margin-left:80px\">6. \u914d\u7f6e\u96c6\u5408 List<\/p>\n<p id=\"7.%20%E9%85%8D%E7%BD%AE%20Map-toc\" style=\"margin-left:80px\">7. \u914d\u7f6e Map<\/p>\n<p id=\"8.%20yml%20%E4%BC%98%E7%BC%BA%E7%82%B9-toc\" style=\"margin-left:80px\">8. yml \u4f18\u7f3a\u70b9<\/p>\n<hr id=\"hr-toc\" \/>\n<h3 id=\"%E2%80%8B%E7%BC%96%E8%BE%91%E4%B8%80%E3%80%81%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9A%84%E4%BD%9C%E7%94%A8\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"512\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021555-6abdc25b2012a.png\" width=\"1664\" \/>\u4e00\u3001\u914d\u7f6e\u6587\u4ef6\u7684\u4f5c\u7528<\/h3>\n<p>Spring Boot \u4e2d\u7684\u914d\u7f6e\u6587\u4ef6\u5e38\u7528\u4e8e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9879\u76ee\u542f\u52a8\u7aef\u53e3<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f&#xff08;URL\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e09\u65b9\u7cfb\u7edf\u8c03\u7528\u5bc6\u94a5<\/p>\n<\/li>\n<li>\n<p>\u65e5\u5fd7\u7ea7\u522b\u3001\u5f02\u5e38\u65e5\u5fd7\u7b49<\/p>\n<\/li>\n<\/ul>\n<p>Spring Boot \u5185\u7f6e Tomcat&#xff0c;\u9ed8\u8ba4\u7aef\u53e3\u662f 8080\u3002\u5982\u679c\u7aef\u53e3\u88ab\u5360\u7528&#xff0c;\u5c31\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u3002<\/p>\n<h3 id=\"%E4%BA%8C%E3%80%81SpringBoot%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F\">\u4e8c\u3001SpringBoot \u914d\u7f6e\u6587\u4ef6\u683c\u5f0f<\/h3>\n<p>Spring Boot \u652f\u6301\u4e09\u79cd\u914d\u7f6e\u6587\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\n<p>application.properites<\/p>\n<\/li>\n<li>\n<p>application.yml<\/p>\n<\/li>\n<li>\n<p>application.yaml<\/p>\n<\/li>\n<\/ul>\n<p>\u5176\u4e2d yml\u662f yaml\u7684\u7b80\u5199&#xff0c;\u5b9e\u9645\u5f00\u53d1\u4e2d\u4f7f\u7528\u9891\u7387\u6700\u9ad8\u3002yaml\u548c yml\u7528\u6cd5\u4e00\u6837&#xff0c;\u8bfe\u5802\u4e2d\u901a\u5e38\u53ea\u8bb2 yml\u3002<\/p>\n<p>\u9879\u76ee\u542f\u52a8\u65f6&#xff0c;Spring Boot \u4f1a\u81ea\u52a8\u4ece classpath \u8def\u5f84\u52a0\u8f7d application.properites \u6216 application.yml \/ application.yaml\u3002<\/p>\n<h4 id=\"1.%20%E5%BF%AB%E9%80%9F%E4%BF%AE%E6%94%B9%E7%AB%AF%E5%8F%A3\">1. \u5feb\u901f\u4fee\u6539\u7aef\u53e3<\/h4>\n<p>\u521b\u5efa Spring Boot \u9879\u76ee\u540e&#xff0c;resources \u76ee\u5f55\u4e0b\u9ed8\u8ba4\u4f1a\u751f\u6210 application.properties\u3002\u4fee\u6539\u7aef\u53e3&#xff1a;<\/p>\n<p>server.port&#061;9090 <\/p>\n<p>\u8fd0\u884c\u540e&#xff0c;\u65e5\u5fd7\u4e2d\u6253\u5370&#xff1a;<\/p>\n<p>Tomcat initialized with port(s): 9090 (http)<br \/>\nTomcat started on port(s): 9090 (http) <\/p>\n<p>\u6b64\u65f6\u8bbf\u95ee http:\/\/127.0.0.1:9090\/login.html \u5373\u53ef&#xff0c;\u539f\u6765\u7684 8080 \u7aef\u53e3\u4e0d\u518d\u751f\u6548\u3002<\/p>\n<hr \/>\n<h4 id=\"2.%20properties%20%E4%B8%8E%20yml%20%E5%85%B1%E5%AD%98\">2. properties \u4e0e yml \u5171\u5b58<\/h4>\n<p>\u7406\u8bba\u4e0a&#xff0c;properties \u548c .yml \u53ef\u4ee5\u540c\u65f6\u5b58\u5728\u540c\u4e00\u4e2a\u9879\u76ee\u4e2d&#xff0c;\u4e24\u4e2a\u914d\u7f6e\u90fd\u4f1a\u52a0\u8f7d&#xff0c;\u5982\u679c\u5185\u5bb9\u51b2\u7a81&#xff0c;\u4ee5 properties \u4e3a\u4e3b&#xff0c;\u6240\u4ee5 properties \u4f18\u5148\u7ea7\u66f4\u9ad8<\/p>\n<p>\u4f46\u5b9e\u9645\u4e1a\u52a1\u4e2d&#xff0c;\u901a\u5e38\u7edf\u4e00\u4f7f\u7528\u4e00\u79cd\u683c\u5f0f&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4&#xff0c;\u964d\u4f4e\u6545\u969c\u7387\u3002<\/p>\n<hr \/>\n<h3 id=\"%E4%B8%89%E3%80%81properties%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\">\u4e09\u3001properties \u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>properties \u662f\u6700\u65e9\u671f\u7684\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f&#xff0c;\u4e5f\u662f\u521b\u5efa Spring Boot \u9879\u76ee\u65f6\u7684\u9ed8\u8ba4\u683c\u5f0f\u3002<\/p>\n<h4 id=\"1.%20%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%C2%A0%E8%BF%9E%E6%8E%A5%EF%BC%9A\">1. \u57fa\u672c\u8bed\u6cd5<span style=\"color:#4d4d4d\">\u00a0\u8fde\u63a5&#xff1a;<\/span><\/h4>\n<p>\u4ee5\u952e\u503c\u5bf9\u5f62\u5f0f\u914d\u7f6e&#xff0c;key \u548c value \u4e4b\u95f4\u4f7f\u7528 &#061; \u8fde\u63a5&#xff1a;<\/p>\n<p>## MySql ##<br \/>\n#\u9a71\u52a8\u7c7b\u540d\u79f0<br \/>\nspring.datasource.driver-class-name&#061;com.mysql.cj.jdbc.Driver<br \/>\n#\u6570\u636e\u5e93\u8fde\u63a5\u7684url<br \/>\nspring.datasource.url&#061;jdbc:mysql:\/\/127.0.0.1:3306\/lottery_system?characterEncoding&#061;utf8&amp;useSSL&#061;false<br \/>\n#\u8fde\u63a5\u6570\u636e\u5e93\u7684\u2f64\u2f3e\u540d<br \/>\nspring.datasource.username&#061;root<br \/>\n#\u8fde\u63a5\u6570\u636e\u5e93\u7684\u5bc6\u7801<br \/>\nspring.datasource.password&#061;123456<\/p>\n<p>## MyBatis ##<br \/>\n#\u914d\u7f6emybatis xml\u7684\u2f42\u4ef6\u8def\u5f84&#xff0c;\u5728 resources\/mapper \u521b\u5efa\u6240\u6709\u8868\u7684 xml \u2f42\u4ef6<br \/>\n#mybatis.mapper-locations&#061;classpath:mapper\/*Mapper.xml<br \/>\n#\u914d\u7f6e\u9a7c\u5cf0\u2f83\u52a8\u8f6c\u6362<br \/>\nmybatis-plus.configuration.map-underscore-to-camel-case&#061;true<br \/>\nmybatis-plus.type-handlers-package&#061;com.example.lotterysystem.dao.handler<br \/>\nmybatis-plus.mapper-locations&#061;classpath:mapper\/*.xml <\/p>\n<h4 id=\"2.%20%E8%AF%BB%E5%8F%96%E9%85%8D%E7%BD%AE\">2. \u8bfb\u53d6\u914d\u7f6e<\/h4>\n<p>\u4f7f\u7528&#064;Value\u6ce8\u89e3\u8bfb\u53d6&#xff0c;\u683c\u5f0f\u4e3a ${key}:<\/p>\n<p>import org.springframework.beans.factory.annotation.Value;<br \/>\nimport org.springframework.web.bind.annotation.RequestMapping;<br \/>\nimport org.springframework.web.bind.annotation.RestController;<\/p>\n<p>&#064;RestController<br \/>\npublic class PropertiesController {<\/p>\n<p>    &#064;Value(&#034;${mykey.key1}&#034;)<br \/>\n    private String key1;<\/p>\n<p>    &#064;RequestMapping(&#034;\/key&#034;)<br \/>\n    public String key() {<br \/>\n        return &#034;\u8bfb\u53d6\u5230\u503c:&#034; &#043; key1;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8bbf\u95ee hhtp:\/\/127.0.0.1:8080\/key&#xff0c;\u9875\u9762\u663e\u793a\u8bfb\u53d6\u5230\u7684\u503c\u3002<\/p>\n<h4 id=\"3.%20%E7%BC%BA%E7%82%B9\">3. \u7f3a\u70b9<\/h4>\n<p>properties \u5b58\u5728\u5927\u91cf\u5197\u4f59\u4fe1\u606f&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>## MySql ##<br \/>\n#\u9a71\u52a8\u7c7b\u540d\u79f0<br \/>\nspring.datasource.driver-class-name&#061;com.mysql.cj.jdbc.Driver<br \/>\n#\u6570\u636e\u5e93\u8fde\u63a5\u7684url<br \/>\nspring.datasource.url&#061;jdbc:mysql:\/\/127.0.0.1:3306\/lottery_system?characterEncoding&#061;utf8&amp;useSSL&#061;false<br \/>\n#\u8fde\u63a5\u6570\u636e\u5e93\u7684\u2f64\u2f3e\u540d<br \/>\nspring.datasource.username&#061;root<br \/>\n#\u8fde\u63a5\u6570\u636e\u5e93\u7684\u5bc6\u7801<br \/>\nspring.datasource.password&#061;123456 <\/p>\n<p>\u6bcf\u4e2a\u914d\u7f6e\u90fd\u8981\u91cd\u590d\u5199 spring.datasource&#xff0c;\u5c42\u7ea7\u5173\u7cfb\u4e0d\u76f4\u89c2\u3002\u800c yml \u53ef\u4ee5\u5f88\u597d\u5730\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<h3 id=\"%E5%9B%9B%E3%80%81yml%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\">\u56db\u3001yml \u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>yml \u662f YAML&#xff08;Yet Another Markup Language&#xff09;\u7684\u7f29\u5199&#xff0c;\u91c7\u7528\u6811\u5f62\u7ed3\u6784&#xff0c;\u53ef\u8bfb\u6027\u66f4\u9ad8\u3002<\/p>\n<h4 id=\"1.%20%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95\">1. \u57fa\u672c\u8bed\u6cd5<\/h4>\n<p>\u57fa\u7840\u8bed\u6cd5\u662f key: value&#xff0c;\u6ce8\u610f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5192\u53f7\u540e\u9762\u5fc5\u987b\u6709\u7a7a\u683c<\/p>\n<\/li>\n<li>\n<p>\u7a7a\u683c\u4e0d\u53ef\u7701\u7565<\/p>\n<\/li>\n<li>\n<p>\u5c42\u7ea7\u4e4b\u95f4\u7528\u6362\u884c\u548c\u7f29\u8fdb\u8868\u793a<\/p>\n<\/li>\n<\/ul>\n<p>\u6b63\u786e\u793a\u4f8b&#xff1a;<\/p>\n<p>key1: java <\/p>\n<p>\u9519\u8bef\u793a\u4f8b&#xff1a;<\/p>\n<p>key2:java  # \u5192\u53f7\u540e\u6ca1\u6709\u7a7a\u683c&#xff0c;\u9519\u8bef <\/p>\n<p>\u4f7f\u7528 yml \u8fde\u63a5\u6570\u636e\u5e93&#xff1a;<\/p>\n<p>spring:<br \/>\n  datasource:<br \/>\n    url: jdbc:mysql:\/\/127.0.0.1:3306\/dbname?characterEncoding&#061;utf8&amp;useSSL&#061;false<br \/>\n    username: root<br \/>\n    password: root <\/p>\n<p>\u5bf9\u6bd4 properties&#xff0c;yml \u6d88\u9664\u4e86\u5197\u4f59&#xff0c;\u5c42\u7ea7\u6e05\u6670\u3002<\/p>\n<h4 id=\"2.%20%E9%85%8D%E7%BD%AE%E4%B8%8D%E5%90%8C%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%8F%8A%20null\">2. \u914d\u7f6e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53ca null<\/h4>\n<p># \u5b57\u7b26\u4e32<br \/>\nstring.value: Hello<\/p>\n<p># \u5e03\u5c14\u503c<br \/>\nboolean.value: true<br \/>\nboolean.value1: false<\/p>\n<p># \u6574\u6570<br \/>\nint.value: 10<\/p>\n<p># \u6d6e\u70b9\u6570<br \/>\nfloat.value: 3.14159<\/p>\n<p># Null&#xff0c;~ \u4ee3\u8868 null<br \/>\nnull.value: ~<\/p>\n<p># \u7a7a\u5b57\u7b26\u4e32&#xff0c;\u76f4\u63a5\u540e\u9762\u4ec0\u4e48\u90fd\u4e0d\u52a0&#xff0c;\u6216\u4f7f\u7528\u5f15\u53f7<br \/>\nempty.value: &#039;&#039; <\/p>\n<h4 id=\"3.%20%E8%AF%BB%E5%8F%96%20yml%20%E9%85%8D%E7%BD%AE\">3. \u8bfb\u53d6 yml \u914d\u7f6e<\/h4>\n<p>\u8bfb\u53d6\u65b9\u5f0f\u4e0e properties \u76f8\u540c&#xff0c;\u4f7f\u7528 &#064;Value&#xff1a;<\/p>\n<p>&#064;RestController<br \/>\npublic class ReadYml {<\/p>\n<p>    &#064;Value(&#034;${string.hello}&#034;)<br \/>\n    private String hello;<\/p>\n<p>    &#064;RequestMapping(&#034;\/ymlKey&#034;)<br \/>\n    public String key() {<br \/>\n        return &#034;\u8bfb\u53d6\u5230\u503c&#xff1a;&#034; &#043; hello;<br \/>\n    }<br \/>\n} <\/p>\n<h4 id=\"4.%20%E5%8D%95%E5%8F%8C%E5%BC%95%E5%8F%B7%E7%9A%84%E5%8C%BA%E5%88%AB\">4. \u5355\u53cc\u5f15\u53f7\u7684\u533a\u522b<\/h4>\n<p>\u5b57\u7b26\u4e32\u9ed8\u8ba4\u4e0d\u7528\u52a0\u5f15\u53f7\u3002\u5982\u679c\u52a0\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7&#xff0c;\u8868\u793a\u7279\u6b8a\u542b\u4e49&#xff1a;<\/p>\n<p>string:<br \/>\n  str1: Hello \\\\n Spring Boot.<br \/>\n  str2: &#039;Hello \\\\n Spring Boot.&#039;<br \/>\n  str3: &#034;Hello \\\\n Spring Boot.&#034; <\/p>\n<p>\u8bfb\u53d6\u4ee3\u7801&#xff1a;<\/p>\n<p>&#064;Value(&#034;${string.str1}&#034;)<br \/>\nprivate String str1;<br \/>\n&#064;Value(&#034;${string.str2}&#034;)<br \/>\nprivate String str2;<br \/>\n&#064;Value(&#034;${string.str3}&#034;)<br \/>\nprivate String str3;<\/p>\n<p>&#064;RequestMapping(&#034;\/yml&#034;)<br \/>\npublic String readYml() {<br \/>\n    System.out.println(str1);<br \/>\n    System.out.println(str2);<br \/>\n    System.out.println(str3);<br \/>\n    return &#034;yml&#034;;<br \/>\n} <\/p>\n<p>\u8f93\u51fa\u7ed3\u679c&#xff1a;<\/p>\n<p>Hello \\\\n Spring Boot.<br \/>\nHello \\\\n Spring Boot.<br \/>\nHello Spring Boot. <\/p>\n<p>\u7ed3\u8bba&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5b57\u7b26\u4e32\u9ed8\u8ba4\u4e0d\u52a0\u5f15\u53f7\u3002<\/p>\n<\/li>\n<li>\n<p>\u5355\u5f15\u53f7\u4f1a\u8f6c\u4e49\u7279\u6b8a\u5b57\u7b26&#xff0c;\\\\n \u4e0d\u518d\u8868\u793a\u6362\u884c&#xff0c;\u800c\u662f\u666e\u901a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u53cc\u5f15\u53f7\u4e0d\u4f1a\u8f6c\u4e49\u7279\u6b8a\u5b57\u7b26&#xff0c;\\\\n \u8868\u793a\u6362\u884c\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"5.%20%E9%85%8D%E7%BD%AE%E5%AF%B9%E8%B1%A1\">5. \u914d\u7f6e\u5bf9\u8c61<\/h4>\n<p>student:<br \/>\n  id: 1<br \/>\n  name: Java<br \/>\n  age: 18 <\/p>\n<p>\u884c\u5185\u5199\u6cd5&#xff1a;<\/p>\n<p>student: {id: 1, name: Java, age: 18} <\/p>\n<p>\u8bfb\u53d6\u5bf9\u8c61\u4e0d\u80fd\u4f7f\u7528 &#064;Value&#xff0c;\u800c\u8981\u7528 &#064;ConfigurationProperties&#xff1a;<\/p>\n<p>import lombok.Data;<br \/>\nimport org.springframework.boot.context.properties.ConfigurationProperties;<br \/>\nimport org.springframework.stereotype.Component;<\/p>\n<p>&#064;ConfigurationProperties(prefix &#061; &#034;student&#034;)<br \/>\n&#064;Component<br \/>\n&#064;Data<br \/>\npublic class Student {<br \/>\n    private int id;<br \/>\n    private String name;<br \/>\n    private int age;<br \/>\n} <\/p>\n<p>\u8c03\u7528&#xff1a;<\/p>\n<p>&#064;RestController<br \/>\npublic class StudentController {<\/p>\n<p>    &#064;Autowired<br \/>\n    private Student student;<\/p>\n<p>    &#064;RequestMapping(&#034;\/readStudent&#034;)<br \/>\n    public String readStudent() {<br \/>\n        return student.toString();<br \/>\n    }<br \/>\n} <\/p>\n<h4 id=\"6.%20%E9%85%8D%E7%BD%AE%E9%9B%86%E5%90%88%20List\">6. \u914d\u7f6e\u96c6\u5408 List<\/h4>\n<p>dbtypes:<br \/>\n  name:<br \/>\n    &#8211; mysql<br \/>\n    &#8211; sqlserver<br \/>\n    &#8211; db2 <\/p>\n<p>\u8bfb\u53d6&#xff1a;<\/p>\n<p>&#064;Component<br \/>\n&#064;ConfigurationProperties(&#034;dbtypes&#034;)<br \/>\n&#064;Data<br \/>\npublic class ListConfig {<br \/>\n    private List&lt;String&gt; name;<br \/>\n}<br \/>\n&#064;RestController<br \/>\npublic class ReadYml2 {<\/p>\n<p>    &#064;Autowired<br \/>\n    private ListConfig listConfig;<\/p>\n<p>    &#064;RequestMapping(&#034;\/readList&#034;)<br \/>\n    public String readList() {<br \/>\n        return listConfig.toString();<br \/>\n    }<br \/>\n} <\/p>\n<h4 id=\"7.%20%E9%85%8D%E7%BD%AE%20Map\">7. \u914d\u7f6e Map<\/h4>\n<p>maptypes:<br \/>\n  map:<br \/>\n    k1: kk1<br \/>\n    k2: kk2<br \/>\n    k3: kk3 <\/p>\n<p>\u884c\u5185\u5199\u6cd5&#xff1a;<\/p>\n<p>maptypes: {map: {k1: kk1, k2: kk2, k3: kk3}} <\/p>\n<p>\u8bfb\u53d6&#xff1a;<\/p>\n<p>&#064;Component<br \/>\n&#064;ConfigurationProperties(&#034;maptypes&#034;)<br \/>\n&#064;Data<br \/>\npublic class MapConfig {<br \/>\n    private HashMap&lt;String, String&gt; map;<br \/>\n}<br \/>\n&#064;RestController<br \/>\npublic class ReadYml2 {<\/p>\n<p>    &#064;Autowired<br \/>\n    private MapConfig mapConfig;<\/p>\n<p>    &#064;RequestMapping(&#034;\/readMap&#034;)<br \/>\n    public String readStudent() {<br \/>\n        return mapConfig.toString();<br \/>\n    }<br \/>\n} <\/p>\n<h4 id=\"8.%20yml%20%E4%BC%98%E7%BC%BA%E7%82%B9\">8. yml \u4f18\u7f3a\u70b9<\/h4>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<li>\n<p>\u53ef\u8bfb\u6027\u9ad8&#xff0c;\u5199\u6cd5\u7b80\u5355&#xff0c;\u6613\u4e8e\u7406\u89e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u66f4\u591a\u6570\u636e\u7c7b\u578b&#xff0c;\u53ef\u4ee5\u7b80\u5355\u8868\u8fbe\u5bf9\u8c61\u3001\u6570\u7ec4\u3001List\u3001Map \u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u5982 Golang\u3001Python\u3001Ruby\u3001JavaScript\u3002<\/p>\n<\/li>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<li>\n<p>\u4e0d\u9002\u5408\u5199\u590d\u6742\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u683c\u5f0f\u8981\u6c42\u4e25\u683c&#xff0c;\u4e00\u4e2a\u7a7a\u683c\u53ef\u80fd\u5f15\u8d77\u9519\u8bef\u3002<\/p>\n<\/li>\n<p>\u4f8b\u5982 properties \u4e2d\u7684\u590d\u6742\u914d\u7f6e&#xff1a;<\/p>\n<p>keycloak.realm&#061;demo<br \/>\nkeycloak.resource&#061;fm-cache-cloud<br \/>\nkeycloak.credentials.secret&#061;d4589683-0ce7-4982-bcd3<br \/>\nkeycloak.security[0].authRoles[0]&#061;user<br \/>\nkeycloak.security[0].collections[0].name&#061;ssologinurl<br \/>\nkeycloak.security[0].collections[0].patterns[0]&#061;\/login\/* <\/p>\n<p>\u8f6c\u6362\u4e3a yml&#xff1a;<\/p>\n<p>keycloak:<br \/>\n  realm: demo<br \/>\n  resource: fm-cache-cloud<br \/>\n  credentials:<br \/>\n    secret: d4589683-0ce7-4982-bcd3<br \/>\n  security:<br \/>\n    &#8211; authRoles:<br \/>\n        &#8211; user<br \/>\n      collections:<br \/>\n        &#8211; name: ssologinurl<br \/>\n          patterns:<br \/>\n            &#8211; \/login\/* <\/p>\n<p>\u8f6c\u6362\u8fc7\u7a0b\u82b1\u8d39\u7cbe\u529b&#xff0c;\u914d\u7f6e\u66f4\u590d\u6742\u65f6\u53ef\u8bfb\u6027\u53cd\u800c\u66f4\u5dee\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55 \u200b\u7f16\u8f91\u4e00\u3001\u914d\u7f6e\u6587\u4ef6\u7684\u4f5c\u7528<br \/>\n\u4e8c\u3001SpringBoot \u914d\u7f6e\u6587\u4ef6\u683c\u5f0f<br \/>\n1. \u5feb\u901f\u4fee\u6539\u7aef\u53e3<br \/>\n2. properties \u4e0e yml \u5171\u5b58<br \/>\n\u4e09\u3001properties \u914d\u7f6e\u6587\u4ef6<br \/>\n1. \u57fa\u672c\u8bed\u6cd5\u00a0\u8fde\u63a5&#xff1a;<br \/>\n2. \u8bfb\u53d6\u914d\u7f6e<br \/>\n3. \u7f3a\u70b9<br \/>\n\u56db\u3001yml \u914d\u7f6e\u6587\u4ef6<br \/>\n1. \u57fa\u672c\u8bed\u6cd5<br \/>\n2. \u914d\u7f6e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53ca null<br \/>\n3. \u8bfb\u53d6 yml \u914d\u7f6e<br \/>\n4. \u5355\u53cc\u5f15\u53f7\u7684\u533a\u522b<br \/>\n5. \u914d\u7f6e\u5bf9\u8c61<br \/>\n6. \u914d\u7f6e\u96c6\u5408 List<br \/>\n7. \u914d\u7f6e Map<br \/>\n8. yml \u4f18\u7f3a\u70b9 \u4e00<\/p>\n","protected":false},"author":2,"featured_media":111464,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-111465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/111465.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u200b\u7f16\u8f91\u4e00\u3001\u914d\u7f6e\u6587\u4ef6\u7684\u4f5c\u7528 \u4e8c\u3001SpringBoot \u914d\u7f6e\u6587\u4ef6\u683c\u5f0f 1. \u5feb\u901f\u4fee\u6539\u7aef\u53e3 2. properties \u4e0e yml \u5171\u5b58 \u4e09\u3001properties \u914d\u7f6e\u6587\u4ef6 1. \u57fa\u672c\u8bed\u6cd5\u00a0\u8fde\u63a5&#xff1a; 2. \u8bfb\u53d6\u914d\u7f6e 3. \u7f3a\u70b9 \u56db\u3001yml \u914d\u7f6e\u6587\u4ef6 1. \u57fa\u672c\u8bed\u6cd5 2. \u914d\u7f6e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53ca null 3. \u8bfb\u53d6 yml \u914d\u7f6e 4. \u5355\u53cc\u5f15\u53f7\u7684\u533a\u522b 5. \u914d\u7f6e\u5bf9\u8c61 6. \u914d\u7f6e\u96c6\u5408 List 7. \u914d\u7f6e Map 8. yml \u4f18\u7f3a\u70b9 \u4e00\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/111465.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-01T02:15:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021555-6abdc25b2012a.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111465.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/111465.html\",\"name\":\"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-01T02:15:57+00:00\",\"dateModified\":\"2026-10-01T02:15:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/111465.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/111465.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111465.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/111465.html","og_locale":"zh_CN","og_type":"article","og_title":"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u200b\u7f16\u8f91\u4e00\u3001\u914d\u7f6e\u6587\u4ef6\u7684\u4f5c\u7528 \u4e8c\u3001SpringBoot \u914d\u7f6e\u6587\u4ef6\u683c\u5f0f 1. \u5feb\u901f\u4fee\u6539\u7aef\u53e3 2. properties \u4e0e yml \u5171\u5b58 \u4e09\u3001properties \u914d\u7f6e\u6587\u4ef6 1. \u57fa\u672c\u8bed\u6cd5\u00a0\u8fde\u63a5&#xff1a; 2. \u8bfb\u53d6\u914d\u7f6e 3. \u7f3a\u70b9 \u56db\u3001yml \u914d\u7f6e\u6587\u4ef6 1. \u57fa\u672c\u8bed\u6cd5 2. \u914d\u7f6e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53ca null 3. \u8bfb\u53d6 yml \u914d\u7f6e 4. \u5355\u53cc\u5f15\u53f7\u7684\u533a\u522b 5. \u914d\u7f6e\u5bf9\u8c61 6. \u914d\u7f6e\u96c6\u5408 List 7. \u914d\u7f6e Map 8. yml \u4f18\u7f3a\u70b9 \u4e00","og_url":"https:\/\/www.wsisp.com\/helps\/111465.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-01T02:15:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021555-6abdc25b2012a.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/111465.html","url":"https:\/\/www.wsisp.com\/helps\/111465.html","name":"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-01T02:15:57+00:00","dateModified":"2026-10-01T02:15:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/111465.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/111465.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/111465.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"SpringBoot \u914d\u7f6e\u6587\u4ef6\u8be6\u89e3\uff1aproperties \u4e0e yml \u4ece\u5165\u95e8\u5230\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=111465"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111465\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/111464"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=111465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=111465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=111465"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=111465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}