{"id":602,"date":"2021-11-01T15:52:11","date_gmt":"2021-11-01T07:52:11","guid":{"rendered":"https:\/\/explause.com\/?p=602"},"modified":"2021-11-01T15:52:11","modified_gmt":"2021-11-01T07:52:11","slug":"%e7%8e%af%e5%a2%83%e6%8a%bd%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/devdoge.org\/?p=602","title":{"rendered":"\u73af\u5883\u62bd\u8c61"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Environment\u63a5\u53e3\u63d0\u4f9b\u4e24\u4e2a\u5173\u4e8e\u5e94\u7528\u73af\u5883\u7684\u6570\u636e\u6a21\u578b\uff1aprofiles\u548cproperties\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">profile\u662f\u4e00\u4e2a\u6709\u540d\u5b57\u7684\u5728\u6fc0\u6d3b\u65f6\u8981\u88ab\u6ce8\u518c\u7684bean\u5b9a\u4e49\u7684\u7ec4\u3002<br>\u65e2\u53ef\u4ee5\u7528xml\u5b9a\u4e49profile\u4e5f\u53ef\u4ee5\u7528\u6ce8\u89e3\u5b9a\u4e49\u3002<br>Environment\u5bf9\u8c61\u7528\u4e8e\u786e\u5b9a\u5f53\u524d\u6fc0\u6d3b\u7684profile\uff0c\u6216\u8005\u9ed8\u8ba4profile\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Properties\u5728\u51e0\u4e4e\u6240\u6709\u7684\u5e94\u7528\u4e2d\u626e\u6f14\u975e\u5e38\u91cd\u8981\u7684\u89d2\u8272\uff0c\u800c\u4e14\u53ef\u4ee5\u6765\u81ea\u4e0d\u540c\u7684\u5730\u65b9\uff1a<br>properties\u6587\u4ef6\u3001JVM\u7cfb\u7edf\u5c5e\u6027\u3001\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001JNDI\u3001servlet\u5bb9\u5668\u53c2\u6570\u7b49\u3002<br>\u548c<code>Environment<\/code>\u5bf9\u8c61\u4e4b\u95f4\u7684\u5173\u7cfb\u662f\u63d0\u4f9b\u7528\u6237\u4fbf\u6377\u7684\u5c5e\u6027\u6e90\u548c\u5c5e\u6027\u89e3\u6790\u63a5\u53e3\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u7528\u4e8ebean\u5b9a\u4e49\u7684profile\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528<code><strong>@Profile<\/strong><\/code>\uff0c\u4f5c\u7528\u5728\u7c7b\u7ea7\u522b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\n@Profile(\"development\")\npublic class StandaloneDataConfig {\n\n    @Bean\n    public DataSource dataSource() {\n        return new EmbeddedDatabaseBuilder()\n            .setType(EmbeddedDatabaseType.HSQL)\n            .addScript(\"classpath:com\/bank\/config\/sql\/schema.sql\")\n            .addScript(\"classpath:com\/bank\/config\/sql\/test-data.sql\")\n            .build();\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u548c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\n@Profile(\"production\")\npublic class JndiDataConfig {\n\n    @Bean(destroyMethod=\"\")\n    public DataSource dataSource() throws Exception {\n        Context ctx = new InitialContext();\n        return (DataSource) ctx.lookup(\"java:comp\/env\/jdbc\/datasource\");\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u751a\u81f3\u53ef\u4ee5\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u7ec4\u6210profile\u8868\u8fbe\u5f0f\uff1a<br>@Profile(&#8220;production &amp; us-east&#8221;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u8981\u591a\u4e2a\u8fd0\u7b97\u7b26\u4e00\u8d77\u7528\uff0c\u5c31<strong>\u5fc5\u987b\u4f7f\u7528\u5706\u62ec\u53f7<\/strong>\uff1a<br>@Profile(&#8220;production &amp; (us-east | eu-central)&#8221;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u5b83\u64cd\u4f5c\u7b26\u4e5f\u662f\u652f\u6301\u7684\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>!<\/code>: \u903b\u8f91\u201cnot\u201d<\/li><li><code>&amp;<\/code>: \u903b\u8f91\u201cand\u201d<\/li><li><code>|<\/code>: \u903b\u8f91\u201cor\u201d<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u5c06<meta charset=\"utf-8\">@Profile\u4f5c\u4e3a\u5143\u6ce8\u89e3\u5b9a\u5236\u81ea\u5df1\u7684\u6ce8\u89e3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.RUNTIME)\n@Profile(\"production\")\npublic @interface Production {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u9ed8\u8ba4\u4e0d\u5bf9\u88ab\u6ce8\u89e3\u7c7b\u7684@Bean\u65b9\u6cd5\u548c@Import\u6ce8\u89e3\u751f\u6548\uff0c\u9664\u975e\u4e00\u4e2a\u6216\u591a\u4e2a\u5bf9\u5e94\u7684profile\u88ab\u6fc0\u6d3b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">@Profile\u6ce8\u89e3\u4e5f\u53ef\u4ee5\u7528\u4e8ebean\u5de5\u5382\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\npublic class AppConfig {\n\n    @Bean(\"dataSource\")\n    @Profile(\"development\") \n    public DataSource standaloneDataSource() {\n        return new EmbeddedDatabaseBuilder()\n            .setType(EmbeddedDatabaseType.HSQL)\n            .addScript(\"classpath:com\/bank\/config\/sql\/schema.sql\")\n            .addScript(\"classpath:com\/bank\/config\/sql\/test-data.sql\")\n            .build();\n    }\n\n    @Bean(\"dataSource\")\n    @Profile(\"production\") \n    public DataSource jndiDataSource() throws Exception {\n        Context ctx = new InitialContext();\n        return (DataSource) ctx.lookup(\"java:comp\/env\/jdbc\/datasource\");\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u5982\u679cbean\u5de5\u5382\u65b9\u6cd5\u6709\u91cd\u8f7d\u7684\uff0c\u5219\u6240\u6709\u91cd\u8f7d\u5de5\u5382\u65b9\u6cd5\u7684@Profile\u6ce8\u89e3\u90fd\u8981\u4fdd\u6301\u4e00\u81f4\uff0c<br>\u5982\u679c\u4e0d\u4e00\u81f4\u5c31\u4f1a\u53d6\u7b2c\u4e00\u4e2a\u58f0\u660e\u751f\u6548\uff0c\u800c\u4e14\u4e5f\u4e0d\u80fd\u7528\u4e8e\u9009\u62e9\u91cd\u8f7d\u65b9\u6cd5\u3002<br>\u5e94\u8be5\u4f7f\u7528\u4e0d\u540c\u7684bean\u5de5\u5382\u65b9\u6cd5\u540d\u751f\u6210\u540c\u4e00\u4e2aname\u5c5e\u6027\u7684bean\uff0c\u5c31\u50cf\u4e0a\u9762\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>XML\u914d\u7f6e\u91cc\u7684profile\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;beans>\u5143\u7d20\u7684profile\u5c5e\u6027\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;beans profile=\"development\"\n    xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xmlns:jdbc=\"http:\/\/www.springframework.org\/schema\/jdbc\"\n    xsi:schemaLocation=\"...\"&gt;\n\n    &lt;jdbc:embedded-database id=\"dataSource\"&gt;\n        &lt;jdbc:script location=\"classpath:com\/bank\/config\/sql\/schema.sql\"\/&gt;\n        &lt;jdbc:script location=\"classpath:com\/bank\/config\/sql\/test-data.sql\"\/&gt;\n    &lt;\/jdbc:embedded-database&gt;\n&lt;\/beans&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u53ef\u4ee5\u5728\u540c\u4e00\u4e2axml\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u5d4c\u5957&lt;beans&gt;\u5143\u7d20\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xmlns:jdbc=\"http:\/\/www.springframework.org\/schema\/jdbc\"\n    xmlns:jee=\"http:\/\/www.springframework.org\/schema\/jee\"\n    xsi:schemaLocation=\"...\"&gt;\n\n    &lt;!-- other bean definitions --&gt;\n\n    &lt;beans profile=\"development\"&gt;\n        &lt;jdbc:embedded-database id=\"dataSource\"&gt;\n            &lt;jdbc:script location=\"classpath:com\/bank\/config\/sql\/schema.sql\"\/&gt;\n            &lt;jdbc:script location=\"classpath:com\/bank\/config\/sql\/test-data.sql\"\/&gt;\n        &lt;\/jdbc:embedded-database&gt;\n    &lt;\/beans&gt;\n\n    &lt;beans profile=\"production\"&gt;\n        &lt;jee:jndi-lookup id=\"dataSource\" jndi-name=\"java:comp\/env\/jdbc\/datasource\"\/&gt;\n    &lt;\/beans&gt;\n&lt;\/beans&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">xml\u914d\u7f6e\u4e0d\u652f\u6301profile\u8868\u8fbe\u5f0f\uff0c\u4f46\u662f\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u5b9e\u73b0\u903b\u8f91and\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xmlns:jdbc=\"http:\/\/www.springframework.org\/schema\/jdbc\"\n    xmlns:jee=\"http:\/\/www.springframework.org\/schema\/jee\"\n    xsi:schemaLocation=\"...\"&gt;\n\n    &lt;!-- other bean definitions --&gt;\n\n    &lt;beans profile=\"production\"&gt;\n        &lt;beans profile=\"us-east\"&gt;\n            &lt;jee:jndi-lookup id=\"dataSource\" jndi-name=\"java:comp\/env\/jdbc\/datasource\"\/&gt;\n        &lt;\/beans&gt;\n    &lt;\/beans&gt;\n&lt;\/beans&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>production<\/code>&nbsp;and&nbsp;<code>us-east<\/code>\u540c\u65f6\u6fc0\u6d3b\u624d\u4f1a\u66b4\u9732dataSource bean\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u6fc0\u6d3bprofile\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u901a\u8fc7ApplicationContext\u7684Environment API\u7f16\u7a0b\u5f0f\u6fc0\u6d3bprofile\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();\nctx.getEnvironment().setActiveProfiles(\"development\");\nctx.register(SomeConfig.class, StandaloneDataConfig.class, JndiDataConfig.class);\nctx.refresh();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216\u8005\u5728property\u91cc\u9762\u6dfb\u52a0spring.profiles.active\u5c5e\u6027\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u540c\u65f6\u6fc0\u6d3b\u591a\u4e2aprofile\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ctx.getEnvironment().setActiveProfiles(\"profile1\", \"profile2\");<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216\u73af\u5883\u53d8\u91cf\u4e2d\u901a\u8fc7\u9017\u53f7\u5206\u9694\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-Dspring.profiles.active=\"profile1,profile2\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u9ed8\u8ba4profile\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ed8\u8ba4\u542f\u7528\u7684profile\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\n@Profile(\"default\")\npublic class DefaultDataConfig {\n\n    @Bean\n    public DataSource dataSource() {\n        return new EmbeddedDatabaseBuilder()\n            .setType(EmbeddedDatabaseType.HSQL)\n            .addScript(\"classpath:com\/bank\/config\/sql\/schema.sql\")\n            .build();\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6ca1\u6709profile\u88ab\u6fc0\u6d3b\u5c31\u521b\u5efadataSource\uff0c\u5f53\u6709profile\u88ab\u6fc0\u6d3b\u65f6\u5c31\u4e0d\u521b\u5efadataSource\u3002<br>\u53ef\u4ee5\u901a\u8fc7Environment API \u7684setDefaultProfiles()\u65b9\u6cd5\u8bbe\u7f6e\u9ed8\u8ba4profile\u540d\u79f0\uff0c<br>\u6216\u8005\u58f0\u660e<strong>spring.profiles.default<\/strong>\u5c5e\u6027\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>PropertySource\u62bd\u8c61\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Environment\u5bf9\u8c61\u5728\u4e00\u7ec4\u53ef\u914d\u7f6e\u7684\u5c42\u7ea7\u7684<code>PropertySource<\/code>\u5bf9\u8c61\u4e2d\u641c\u7d22\u5c5e\u6027\u503c\uff0c<code>PropertySource<\/code>\u662f\u5bf9\u4e8e\u952e\u503c\u5bf9\u7684\u7b80\u5355\u62bd\u8c61\u3002<br>Spring\u7684<code>StandardEnvironment<\/code>\u7531\u4e24\u4e2aPropertySource\u5bf9\u8c61\u914d\u7f6e\u6210\uff0c\u4e00\u4e2a\u8868\u793aJVM\u7cfb\u7edf\u5c5e\u6027\uff0c\u53e6\u4e00\u4e2a\u8868\u793a\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u641c\u7d22\u64cd\u4f5c\u5177\u6709\u5c42\u7ea7\u5173\u7cfb\uff0c\u5c5e\u6027\u53d8\u91cf\u6709\u4f18\u5148\u7ea7\uff0c\u9ed8\u8ba4\u7cfb\u7edf\u5c5e\u6027\u7ea7\u522b\u5927\u4e8e\u73af\u5883\u53d8\u91cf\uff0c\u6bd4\u5982my-property\u5c5e\u6027\u540c\u65f6\u51fa\u73b0\u5728\u7cfb\u7edf\u5c5e\u6027\u548c\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u5219\u8c03\u7528env.getProperty(&#8220;my-property&#8221;)\u5c31\u4f1a\u8fd4\u56de\u7cfb\u7edf\u5c5e\u6027\u4e2d\u7684\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728StandardServletEnvironment\u4e2d\uff0c\u5b8c\u6574\u7684\u4f18\u5148\u7ea7\u987a\u5e8f\u662f\uff1a\uff081\u4e3a\u6700\u9ad8\uff09<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>ServletConfig parameters (\u4f8b\u5982\uff1a<code>DispatcherServlet<\/code>\u00a0context)<\/li><li>ServletContext parameters (web.xml context-param entries)<\/li><li>JNDI environment variables (<code>java:comp\/env\/<\/code>\u00a0entries)<\/li><li>JVM system properties (<code>-D<\/code>\u00a0command-line arguments)<\/li><li>JVM system environment (\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u53d8\u91cf)<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u7684\u6574\u4e2a\u673a\u5236\u90fd\u662f\u53ef\u4ee5\u914d\u7f6e\u7684\uff0c\u6bd4\u5982\u6dfb\u52a0\u81ea\u5df1\u7684<code>PropertySource<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ConfigurableApplicationContext ctx = new GenericApplicationContext();\nMutablePropertySources sources = ctx.getEnvironment().getPropertySources();\nsources.addFirst(new MyPropertySource());<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u4e2d\uff0cMyPropertySource\u88ab\u8bbe\u7f6e\u6210\u4e86\u6700\u9ad8\u4f18\u5148\u7ea7\u3002<br><code>MutablePropertySources<\/code> API\u66b4\u9732\u4e86\u4e00\u4e9b\u7cbe\u786e\u64cd\u4f5c<code>PropertySource<\/code>\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u4f7f\u7528@PropertySource\u6ce8\u89e3\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u4fbf\u5feb\u6377\u5730\u5411Environment\u6dfb\u52a0PropertySource\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u53c2\u6570\u662f\u67d0\u4e2a\u542b\u6709\u952e\u503c\u5bf9\u4fe1\u606f\u7684\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\n@PropertySource(\"classpath:app.properties\")\npublic class AppConfig {\n\n    @Autowired\n    Environment env;\n\n    @Bean\n    public TestBean testBean() {\n        TestBean testBean = new TestBean();\n        testBean.setName(env.getProperty(\"testbean.name\"));\n        return testBean;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ea\u8981\u5728app.properties\u6587\u4ef6\u91cc\u6dfb\u52a0<strong>testbean.name=beanName<\/strong>\u5c31\u53ef\u7ed9testBean\u547d\u540d\u3002<br>\u4efb\u4f55${\u2026\u200b}\u5360\u4f4d\u7b26\u90fd\u4f1a\u5728\u8bfb\u53d6Environment\u4e4b\u524d\u88ab\u89e3\u6790\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\n@PropertySource(\"classpath:\/com\/${my.placeholder:default\/path}\/app.properties\")\npublic class AppConfig {\n\n    @Autowired\n    Environment env;\n\n    @Bean\n    public TestBean testBean() {\n        TestBean testBean = new TestBean();\n        testBean.setName(env.getProperty(\"testbean.name\"));\n        return testBean;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4e0d\u80fd\u89e3\u6790my.placeholder\uff0c\u5c31\u4f7f\u7528\u5192\u53f7\u540e\u9762\u7684default\/path\u4f5c\u4e3a\u503c\uff0c\u5192\u53f7\u540e\u9762\u662f\u9ed8\u8ba4\u503c\u3002<br>\u5982\u679c\u4e0d\u63d0\u4f9b\u9ed8\u8ba4\u503c\uff0c\u5f53my.placeholder\u65e0\u6cd5\u89e3\u6790\u65f6\u5c31\u4f1a\u629b\u51faIllegalArgumentException\u5f02\u5e38\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">@PropertySource\u53ef\u4ee5\u91cd\u590d\u58f0\u660e\uff0c\u53ea\u662f\u9700\u8981\u5728\u540c\u4e00\u7b49\u7ea7\uff0c\u53ea\u80fd\u9009\u76f4\u63a5\u4f7f\u7528\u8fd8\u662f\u7528\u5b9a\u5236\u7684\u6ce8\u89e3\u3002\u6df7\u7528\u4e0d\u540c\u7b49\u7ea7\u7684\u6ce8\u89e3\u65f6\uff0c\u76f4\u63a5\u4f7f\u7528<meta charset=\"utf-8\">@PropertySource\u4f1a\u8986\u76d6\u5b9a\u5236\u7684\u6ce8\u89e3\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u8bed\u53e5\u4e2d\u7684\u5360\u4f4d\u7b26\u7684\u89e3\u6790\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5386\u53f2\u4e0a\uff0c\u5360\u4f4d\u7b26\u53ea\u80fd\u89e3\u6790\u7cfb\u7edf\u5c5e\u6027\u548c\u73af\u5883\u53d8\u91cf\u3002<br>\u73b0\u5728\u53ea\u8981\u662f\u5728Environment\u4e2d\u5b58\u5728\u7684\u503c\u90fd\u53ef\u4ee5\u89e3\u6790\uff0c\u65e0\u5173\u5c5e\u6027\u5728\u4ec0\u4e48\u5730\u65b9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;beans&gt;\n    &lt;import resource=\"com\/bank\/service\/${customer}-config.xml\"\/&gt;\n&lt;\/beans&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Spring\u73af\u5883\u53d8\u91cf\uff0c\u65b9\u4fbf\u5bfc\u5165\u6570\u636e\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[28],"class_list":["post-602","post","type-post","status-publish","format-standard","hentry","category-ioc","tag-ioc"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=602"}],"version-history":[{"count":3,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions"}],"predecessor-version":[{"id":605,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions\/605"}],"wp:attachment":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}