{"id":705,"date":"2023-11-15T00:15:17","date_gmt":"2023-01-18T01:11:15","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/"},"modified":"2025-08-03T04:02:36","modified_gmt":"2025-08-02T20:02:36","slug":"%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/","title":{"rendered":"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668"},"content":{"rendered":"<h1>Spring\u7684@PropertySource<\/h1>\n<p>Spring\u7684@PropertySource\u6ce8\u89e3\u7528\u4e8e\u5411Spring\u73af\u5883\u63d0\u4f9b\u5c5e\u6027\u6587\u4ef6\u3002\u8be5\u6ce8\u89e3\u901a\u5e38\u4e0e@Configuration\u7c7b\u4e00\u8d77\u4f7f\u7528\u3002Spring\u7684PropertySource\u6ce8\u89e3\u662f\u53ef\u91cd\u590d\u7684\uff0c\u8fd9\u610f\u5473\u7740\u53ef\u4ee5\u5728\u4e00\u4e2a@Configuration\u7c7b\u4e0a\u4f7f\u7528\u591a\u4e2aPropertySource\u6ce8\u89e3\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fJava 8\u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u6b64\u529f\u80fd\u3002<\/p>\n<h2>\u4e00\u4e2aSpring PropertySource\u7684\u4f8b\u5b50<\/h2>\n<p>\u8ba9\u6211\u4eec\u5feb\u901f\u6d4f\u89c8\u4e00\u4e2a\u7b80\u5355\u7684Spring\u5e94\u7528\u7a0b\u5e8f\uff0c\u6211\u4eec\u5c06\u4ece\u5c5e\u6027\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u636e\u5e93\u914d\u7f6e\u8be6\u7ec6\u4fe1\u606f\u5e76\u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\u3002\u6211\u4eec\u5c06\u5728\u63a7\u5236\u53f0\u6253\u5370\u4e00\u4e9b\u6570\u636e\u5e93\u7684\u5143\u6570\u636e\u4fe1\u606f\u3002\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684maven\u9879\u76ee\u5e76\u6dfb\u52a0Spring\u548cMySQL\u4f9d\u8d56\u9879\u3002\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u6570\u636e\u5e93\u4f5c\u4e3a\u793a\u4f8b\uff0c\u53ea\u9700\u76f8\u5e94\u5730\u66f4\u6539\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;dependency&gt;\r\n\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;spring-context&lt;\/artifactId&gt;\r\n\t&lt;version&gt;5.0.6.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;mysql&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\r\n\t&lt;version&gt;5.1.46&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564806fa4b2f92e6c72e531\/4-0.png\" alt=\"Spring PropertySource Example\" \/><\/div>\n<pre class=\"post-pre\"><code>package com.Olivia.spring;\r\n\r\nimport java.sql.Connection;\r\nimport java.sql.DriverManager;\r\nimport java.sql.SQLException;\r\n\r\npublic class DBConnection {\r\n\r\n\tprivate String driverClass;\r\n\tprivate String dbURL;\r\n\tprivate String userName;\r\n\tprivate char[] password;\r\n\tprivate Connection con;\r\n\r\n\tpublic DBConnection(String driverClass, String dbURL, String userName, char[] password) {\r\n\t\tthis.driverClass = driverClass;\r\n\t\tthis.dbURL = dbURL;\r\n\t\tthis.userName = userName;\r\n\t\tthis.password = password;\r\n\t}\r\n\r\n\tpublic Connection getConnection() {\r\n\t\tif (this.con != null)\r\n\t\t\treturn con;\r\n\r\n\t\tConnection con = null;\r\n\t\ttry {\r\n\t\t\tSystem.out.println(\"Creating DB Connection\");\r\n\t\t\tClass.forName(driverClass);\r\n\t\t\tcon = DriverManager.getConnection(dbURL, userName, String.valueOf(password));\r\n\t\t\tSystem.out.println(\"Successfully Created DB Connection\");\r\n\t\t} catch (ClassNotFoundException | SQLException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\tthis.con = con;\r\n\t\treturn con;\r\n\t}\r\n\r\n\tpublic void close() {\r\n\t\tSystem.out.println(\"DBConnection close called\");\r\n\t\tif (this.con != null) {\r\n\t\t\ttry {\r\n\t\t\t\tcon.close();\r\n\t\t\t} catch (SQLException e) {\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u4f60\u6b63\u5728\u521b\u5efa\u4e00\u4e2a\u771f\u5b9e\u4e16\u754c\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528Spring ORM\u3002\u8fd9\u6837\uff0cSpring\u5c06\u8d1f\u8d23\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7ba1\u7406\uff0c\u4f60\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u7f16\u5199\u4e1a\u52a1\u903b\u8f91\u3002\u73b0\u5728\u8ba9\u6211\u4eec\u521b\u5efa\u4e00\u4e2aSpring\u914d\u7f6e\u7c7b\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u5c06\u4f7f\u7528PropertySource\u6ce8\u89e3\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.Olivia.spring;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.context.annotation.PropertySource;\r\nimport org.springframework.core.env.Environment;\r\n\r\n@Configuration\r\n@PropertySource(\"classpath:db.properties\")\r\n@PropertySource(\"classpath:root.properties\")\r\npublic class DBConfiguration {\r\n\r\n\t@Autowired\r\n    Environment env;\r\n\t\r\n\t@Bean\r\n    public DBConnection getDBConnection() {\r\n\t\tSystem.out.println(\"Getting DBConnection Bean for App: \"+env.getProperty(\"APP_NAME\"));\r\n\t\tDBConnection dbConnection = new DBConnection(env.getProperty(\"DB_DRIVER_CLASS\"), env.getProperty(\"DB_URL\"), env.getProperty(\"DB_USERNAME\"), env.getProperty(\"DB_PASSWORD\").toCharArray());\r\n        return dbConnection;\r\n    }\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>\u6ce8\u610f\u5230\u6211\u6b63\u5728\u5c06\u591a\u4e2a\u5c5e\u6027\u6587\u4ef6\u52a0\u8f7d\u5230Spring\u73af\u5883\u4e2d\u3002\u8ba9\u6211\u4eec\u6765\u770b\u770b\u8fd9\u4e9b\u5c5e\u6027\u6587\u4ef6\u7684\u5185\u5bb9\u3002db.properties<\/p>\n<pre class=\"post-pre\"><code>#MYSQL Database Configurations\r\nDB_DRIVER_CLASS=com.mysql.jdbc.Driver\r\nDB_URL=jdbc:mysql:\/\/localhost:3306\/Test\r\nDB_USERNAME=scdev\r\nDB_PASSWORD=scdev\r\n<\/code><\/pre>\n<p>\u6839\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre class=\"post-pre\"><code>APP_NAME=PropertySource Example\r\n<\/code><\/pre>\n<p>\u8ba9\u6211\u4eec\u521b\u5efa\u4e3b\u7c7b\u5e76\u83b7\u53d6\u6570\u636e\u5e93\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.Olivia.spring;\r\n\r\nimport java.sql.Connection;\r\nimport java.sql.SQLException;\r\n\r\nimport org.springframework.context.annotation.AnnotationConfigApplicationContext;\r\n\r\npublic class SpringMainClass {\r\n\r\n\tpublic static void main(String[] args) throws SQLException {\r\n\t\tAnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();\r\n\t\tcontext.scan(\"com.Olivia.spring\");\r\n\t\tcontext.refresh();\r\n\r\n\t\tDBConnection dbConnection = context.getBean(DBConnection.class);\r\n\r\n\t\tConnection con = dbConnection.getConnection();\r\n\r\n\t\tSystem.out.println(con.getMetaData().getDatabaseProductName());\r\n\t\tSystem.out.println(con.getMetaData().getDatabaseProductVersion());\r\n\r\n\t\t\/\/ close the spring context\r\n\t\tcontext.close();\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u53ea\u9700\u5c06\u4e0a\u8ff0\u7c7b\u4f5c\u4e3aJava\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\uff0c\u5b83\u5c06\u4ea7\u751f\u4ee5\u4e0b\u8f93\u51fa\u3002<\/p>\n<pre class=\"post-pre\"><code>Getting DBConnection Bean for App: PropertySource Example\r\nCreating DB Connection\r\nSuccessfully Created DB Connection\r\nMySQL\r\n5.7.18\r\nDBConnection close called\r\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u63d0\u9ad8\u53ef\u8bfb\u6027\uff0c\u6211\u5df2\u5220\u9664\u4e86Spring\u65e5\u5fd7\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u7684\u8c03\u8bd5\u4fe1\u606f\u3002<\/p>\n<h2>Spring @PropertySource \u591a\u4e2a\u6587\u4ef6 &#8211; @PropertySources<\/h2>\n<p>\u6709\u53e6\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4e3a\u914d\u7f6e\u7c7b\u52a0\u8f7d\u591a\u4e2a\u5c5e\u6027\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>@PropertySources({\r\n@PropertySource(\"classpath:db.properties\"),\r\n@PropertySource(\"classpath:root.properties\")})\r\npublic class DBConfiguration {\r\n}\r\n<\/code><\/pre>\n<p>\u4eceJava 8\u5f00\u59cb\uff0cPropertySource\u6ce8\u89e3\u6210\u4e3a\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u3002\u5bf9\u4e8e\u65e9\u671f\u7684Java\u7248\u672c\uff0c@PropertySources\u662f\u4e3a\u914d\u7f6e\u7c7b\u63d0\u4f9b\u591a\u4e2a\u5c5e\u6027\u6587\u4ef6\u7684\u65b9\u5f0f\u3002<\/p>\n<h2>\u8986\u76d6Spring PropertySource\u7684\u503c<\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06\u591a\u4e2a\u5c5e\u6027\u6587\u4ef6\u52a0\u8f7d\u5230Spring\u73af\u5883\u4e2d\u3002\u5982\u679c\u591a\u4e2a\u6587\u4ef6\u4e2d\u5b58\u5728\u76f8\u540c\u7684\u952e\uff0c\u5219\u6700\u540e\u52a0\u8f7d\u7684\u5c5e\u6027\u6587\u4ef6\u5c06\u8986\u76d6\u5148\u524d\u7684\u503c\u3002\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u7684\u5c5e\u6027\u503c\u4e0d\u7b26\u5408\u9884\u671f\uff0c\u8bf7\u68c0\u67e5\u5176\u4ed6\u5c5e\u6027\u6587\u4ef6\u4e2d\u662f\u5426\u5b58\u5728\u76f8\u540c\u7684\u952e\uff0c\u4ee5\u53ca\u52a0\u8f7d\u8fd9\u4e9b\u5c5e\u6027\u6587\u4ef6\u7684\u987a\u5e8f\u662f\u4ec0\u4e48\u3002<\/p>\n<h2>Spring \u5c5e\u6027\u6e90\u5916\u90e8\u6587\u4ef6<\/h2>\n<p>\u6709\u65f6\u5019\u6211\u4eec\u7684\u914d\u7f6e\u6587\u4ef6\u4f1a\u5b58\u5728\u7279\u5b9a\u7684\u4f4d\u7f6e\uff0c\u5b83\u4eec\u5e76\u4e0d\u5c5e\u4e8e\u9879\u76ee\u7684\u7c7b\u8def\u5f84\u3002\u6211\u4eec\u53ef\u4ee5\u914d\u7f6ePropertySource\u6765\u4ece\u6587\u4ef6\u7cfb\u7edf\u52a0\u8f7d\u5c5e\u6027\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>@PropertySource(\"file:\/Users\/scdev\/db.properties\")\r\n<\/code><\/pre>\n<h2>Spring\u5c5e\u6027\u6e90\u73af\u5883\u53d8\u91cf<\/h2>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e0a\u8ff0\u914d\u7f6e\u4ece\u5916\u90e8\u4f4d\u7f6e\u8bfb\u53d6\u5c5e\u6027\u6587\u4ef6\u7684\u65b9\u5f0f\u5728\u6211\u7684\u672c\u5730\u7cfb\u7edf\u4e0a\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u4f46\u5bf9\u5176\u4ed6\u4eba\u6216\u670d\u52a1\u5668\u5219\u4e0d\u9002\u7528\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728PropertySource\u4e2d\u8bfb\u53d6\u7cfb\u7edf\u53d8\u91cf\uff0c\u6240\u4ee5\u4e0b\u9762\u7684\u914d\u7f6e\u5bf9\u6bcf\u4e2a\u4eba\u90fd\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>@PropertySource(\"file:${HOME}\/db.properties\")\r\n<\/code><\/pre>\n<h2>Spring PropertySource\u5ffd\u7565FileNotFoundException<\/h2>\n<p>\u5982\u679c\u627e\u4e0d\u5230\u5c5e\u6027\u6587\u4ef6\uff0c\u5219\u4f1a\u51fa\u73b0FileNotFoundException\u3002\u6709\u65f6\uff0c\u6211\u4eec\u4e0d\u5e0c\u671b\u629b\u51fa\u5f02\u5e38\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e5f\u53ef\u4ee5\u4f7f\u7528\u9ed8\u8ba4\u503c\u5de5\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u5c06PropertySource\u4e2d\u7684ignoreResourceNotFound\u8bbe\u7f6e\u4e3atrue\uff0c\u4ee5\u544a\u8bc9Spring\u6846\u67b6\u5728\u627e\u4e0d\u5230\u6587\u4ef6\u65f6\u4e0d\u8981\u629b\u51fa\u5f02\u5e38\u3002<\/p>\n<pre class=\"post-pre\"><code>@PropertySource(value = \"classpath:root.properties\", ignoreResourceNotFound=true)\r\n<\/code><\/pre>\n<p>\u8fd9\u5c31\u662f\u5173\u4e8eSpring PropertySource\u793a\u4f8b\u7684\u6240\u6709\u5185\u5bb9\u4e86\u3002\u60a8\u53ef\u4ee5\u4ece\u6211\u4eec\u7684GitHub\u4ed3\u5e93\u4e2d\u67e5\u770b\u6e90\u4ee3\u7801\u548cMaven\u9879\u76ee\u3002<\/p>\n<p>Spring\u5c5e\u6027\u6e90\u9879\u76ee<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring\u7684@PropertySource Spring\u7684@PropertySource\u6ce8\u89e3\u7528\u4e8e\u5411Sprin [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1947,1948,1089,1547,1116],"class_list":{"0":"post-705","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-propertysource","8":"tag-java","9":"tag-spring","11":"tag-1116"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002\" \/>\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.silicloud.com\/zh\/blog\/\u6625\u5929\u7684-propertysource\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668\" \/>\n<meta property=\"og:description\" content=\"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6625\u5929\u7684-propertysource\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-18T01:11:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-02T20:02:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564806fa4b2f92e6c72e531\/4-0.png\" \/>\n<meta name=\"author\" content=\"\u96c5, \u609f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u96c5, \u609f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/\",\"name\":\"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-01-18T01:11:15+00:00\",\"dateModified\":\"2025-08-02T20:02:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\"},\"description\":\"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\",\"name\":\"\u96c5, \u609f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"caption\":\"\u96c5, \u609f\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668 - Blog - Silicon Cloud","description":"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002","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.silicloud.com\/zh\/blog\/\u6625\u5929\u7684-propertysource\/","og_locale":"zh_CN","og_type":"article","og_title":"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668","og_description":"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u6625\u5929\u7684-propertysource\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-18T01:11:15+00:00","article_modified_time":"2025-08-02T20:02:36+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564806fa4b2f92e6c72e531\/4-0.png"}],"author":"\u96c5, \u609f","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u96c5, \u609f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/","name":"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-01-18T01:11:15+00:00","dateModified":"2025-08-02T20:02:36+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6"},"description":"\u6df1\u5165\u89e3\u6790Spring\u6846\u67b6\u4e2d@PropertySource\u6ce8\u89e3\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7@PropertySource\u52a0\u8f7d\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u5c5e\u6027\u503c\u7684\u52a8\u6001\u6ce8\u5165\uff0c\u662fSpring\u5f00\u53d1\u8005\u5fc5\u5907\u7684\u6280\u672f\u77e5\u8bc6\u70b9\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Spring\u6846\u67b6\u4e2d\u7684@PropertySource\u6ce8\u89e3\u8be6\u89e3\uff1a\u914d\u7f6e\u5c5e\u6027\u6587\u4ef6\u7684\u5229\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6","name":"\u96c5, \u609f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","caption":"\u96c5, \u609f"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%98%a5%e5%a4%a9%e7%9a%84-propertysource\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=705"}],"version-history":[{"count":3,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions"}],"predecessor-version":[{"id":110531,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions\/110531"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}