{"id":55361,"date":"2025-08-13T21:14:53","date_gmt":"2025-08-13T13:14:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/55361.html"},"modified":"2025-08-13T21:14:53","modified_gmt":"2025-08-13T13:14:53","slug":"spring%ef%bc%88%e5%85%a8%e7%bd%91%e6%9c%80%e8%af%a6%e7%bb%86%ef%bc%89%e5%80%bc%e5%be%97%e6%94%b6%e8%97%8f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/55361.html","title":{"rendered":"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf"},"content":{"rendered":"<h3 id=\"spring\u4ecb\u7ecd\" style=\"background-color:transparent;margin-left:0px;margin-right:0px;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u4ecb\u7ecd<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20230829151858869\" height=\"464\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131449-689c8fc91f59e.png\" width=\"1512\"><\/p>\n<h4 id=\"\u4ec0\u4e48\u662fspring\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u4ec0\u4e48\u662fSpring<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u662f\u4e00\u4e2a\u5f00\u6e90\u6846\u67b6\uff0c\u4e3a\u7b80\u5316\u4f01\u4e1a\u7ea7\u5f00\u53d1\u800c\u751f\u3002\u5b83\u4ee5IOC\uff08\u63a7\u5236\u53cd\u8f6c\uff09\u548cAOP\uff08\u9762\u5411\u5207\u9762\uff09\u4e3a\u601d\u60f3\u5185\u6838\uff0c\u63d0\u4f9b\u4e86\u63a7\u5236\u5c42SpringMVC\u3001\u6570\u636e\u5c42SpringData\u3001\u670d\u52a1\u5c42\u4e8b\u52a1\u7ba1\u7406\u7b49\u4f17\u591a\u6280\u672f\uff0c\u5e76\u53ef\u4ee5\u6574\u5408\u4f17\u591a\u7b2c\u4e09\u65b9\u6846\u67b6\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u5c06\u5f88\u591a\u590d\u6742\u7684\u4ee3\u7801\u53d8\u5f97\u4f18\u96c5\u7b80\u6d01\uff0c\u6709\u6548\u7684\u964d\u4f4e\u4ee3\u7801\u7684\u8026\u5408\u5ea6\uff0c\u6781\u5927\u7684\u65b9\u4fbf\u9879\u76ee\u7684\u540e\u671f\u7ef4\u62a4\u3001\u5347\u7ea7\u548c\u6269\u5c55\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u5b98\u7f51\u5730\u5740\uff1aSpring | Home<\/span><\/span><\/p>\n<h4 id=\"spring6\u7248\u672c\u4ecb\u7ecd\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring6\u7248\u672c\u4ecb\u7ecd<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2022\u5e74\u5e95\uff0cSpring\u6b63\u5f0f\u53d1\u5e03Spring6\uff0c\u6b64\u65f6\u8ddd\u79bbSpring5\u53d1\u5e03\u5df2\u7ecf\u6709\u56db\u5e74\u591a\u4e86\u3002Spring6\u662f\u4e00\u4e2a\u8de8\u8d8a\u5f0f\u7684\u5347\u7ea7\uff1a<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6574\u4e2a\u6846\u67b6\u652f\u6301\u7684\u6700\u4f4eJDK\u7248\u672c\u76f4\u63a5\u8de8\u8d8a\u5230 JDK17\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Servlet\u3001JPA \u7b49\u4ecejavax\u8fc1\u79fb\u5230jakarta\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u517c\u5bb9jakarta EE 9 \u3001jakarta EE 10\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u652f\u6301AOT\u6280\u672f\u3002<\/p>\n<\/li>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u672c\u6b21\u5347\u7ea7\u66f4\u591a\u662f\u4e3a\u4e86SpringBoot\u5347\u7ea7\u52303.0\u505a\u51c6\u5907\uff0c\u6211\u4eec\u4e5f\u5c06\u5728SpringBoot3.0\u4e2d\u8be6\u7ec6\u8bb2\u89e3AOT\u7b49\u65b0\u7248\u7684\u529f\u80fd\u3002<\/span><\/span><\/p>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u7684\u601d\u60f3\u5185\u6838\u662f<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u63a7\u5236\u53cd\u8f6c\u548c\u9762\u5411\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u63a7\u5236\u53cd\u8f6c\u548c\u9762\u5411\u8fc7\u7a0b<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u63a7\u5236\u53cd\u8f6c\u548c\u9762\u5411\u5207\u9762<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u63a7\u5236\u53cd\u8f6c\u548c\u9762\u5411\u63a5\u53e3<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;C<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<h3 id=\"spring\u4f53\u7cfb\u7ed3\u6784\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u4f53\u7cfb\u7ed3\u6784<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211202103309145\" height=\"524\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131449-689c8fc988d04.png\" width=\"1239\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u6846\u67b6\u6839\u636e\u4e0d\u540c\u7684\u529f\u80fd\u88ab\u5212\u5206\u6210\u4e86\u591a\u4e2a\u6a21\u5757\uff0c\u8fd9\u4e9b\u6a21\u5757\u53ef\u4ee5\u6ee1\u8db3\u4e00\u5207\u4f01\u4e1a\u7ea7\u5e94\u7528\u5f00\u53d1\u7684\u9700\u6c42\uff0c\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u6709\u9009\u62e9\u6027\u5730\u4f7f\u7528\u6240\u9700\u8981\u7684\u6a21\u5757\u3002<\/span><\/span><\/p>\n<ul style=\"margin-left:0;margin-right:0\">\n<li>\n<p style=\"margin-left:0;margin-right:0\">Core Container\uff1aSpring\u6838\u5fc3\u6a21\u5757\uff0c\u4efb\u4f55\u529f\u80fd\u7684\u4f7f\u7528\u90fd\u79bb\u4e0d\u5f00\u8be5\u6a21\u5757\uff0c\u662f\u5176\u4ed6\u6a21\u5757\u5efa\u7acb\u7684\u57fa\u7840\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Data Access\/Integration\uff1a\u8be5\u6a21\u5757\u63d0\u4f9b\u4e86\u6570\u636e\u6301\u4e45\u5316\u7684\u76f8\u5e94\u529f\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Web\uff1a\u8be5\u6a21\u5757\u63d0\u4f9b\u4e86web\u5f00\u53d1\u7684\u76f8\u5e94\u529f\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">AOP\uff1a\u63d0\u4f9b\u4e86\u9762\u5411\u5207\u9762\u7f16\u7a0b\u5b9e\u73b0<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Aspects\uff1a\u63d0\u4f9b\u4e0eAspectJ\u6846\u67b6\u7684\u96c6\u6210\uff0c\u8be5\u6846\u67b6\u662f\u4e00\u4e2a\u9762\u5411\u5207\u9762\u7f16\u7a0b\u6846\u67b6\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Instrumentation\uff1a\u63d0\u4f9b\u4e86\u7c7b\u5de5\u5177\u7684\u652f\u6301\u548c\u7c7b\u52a0\u8f7d\u5668\u7684\u5b9e\u73b0\uff0c\u53ef\u4ee5\u5728\u7279\u5b9a\u7684\u5e94\u7528\u670d\u52a1\u5668\u4e2d\u4f7f\u7528\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Messaging\uff1a\u4e3aSpring\u6846\u67b6\u96c6\u6210\u4e00\u4e9b\u57fa\u7840\u7684\u62a5\u6587\u4f20\u9001\u5e94\u7528<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">Test\uff1a\u63d0\u4f9b\u4e0e\u6d4b\u8bd5\u6846\u67b6\u7684\u96c6\u6210<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-2\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u7684\u6838\u5fc3\u6a21\u5757\u662f<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;Core Container<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;Web<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;AOP<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;Data Access\/Integration<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. \u5173\u4e8eSpring\u6a21\u5757\uff0c\u8bf4\u6cd5\u6b63\u786e\u7684\u662f<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5fc5\u987b\u4f7f\u7528\u6240\u6709\u6a21\u5757<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;Test\u6a21\u5757\u63d0\u4f9b\u4e86web\u5f00\u53d1\u7684\u76f8\u5e94\u529f\u80fd<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u4efb\u4f55\u529f\u80fd\u7684\u4f7f\u7528\u90fd\u79bb\u4e0d\u5f00Spring\u6838\u5fc3\u6a21\u5757<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;Web\u6a21\u5757\u662fSpring\u6838\u5fc3\u6a21\u5757<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;A&nbsp;2=&gt;C<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<h3 id=\"ioc\u63a7\u5236\u53cd\u8f6c\u601d\u60f3\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u63a7\u5236\u53cd\u8f6c\u601d\u60f3<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126165759417\" height=\"659\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fca267e5.png\" width=\"659\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC(Inversion of Control) \uff1a\u7a0b\u5e8f\u5c06\u521b\u5efa\u5bf9\u8c61\u7684\u6743\u5229\u4ea4\u7ed9\u6846\u67b6\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u4e4b\u524d\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u5bf9\u8c61\u5b9e\u4f8b\u7684\u521b\u5efa\u662f\u7531\u8c03\u7528\u8005\u7ba1\u7406\u7684\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/span><\/p>\n<p>public interface StudentDao {<br \/>\n  \/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f<br \/>\n  Student findById(int id);<br \/>\n}<\/p>\n<p>public class StudentDaoImpl implements StudentDao{<br \/>\n  @Override<br \/>\n  public Student findById(int id) {<br \/>\n    \/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f<br \/>\n    return new Student(1,\\&#8221;\u767e\u6218\u7a0b\u5e8f\u5458\\&#8221;,\\&#8221;\u5317\u4eac\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<p>public class StudentService {<br \/>\n  public Student findStudentById(int id){<br \/>\n    \/\/ \u6b64\u5904\u5c31\u662f\u8c03\u7528\u8005\u5728\u521b\u5efa\u5bf9\u8c61<br \/>\n    StudentDao studentDao = new StudentDaoImpl();<br \/>\n    return studentDao.findById(1);<br \/>\n   }<br \/>\n}<\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u8fd9\u79cd\u5199\u6cd5\u6709\u4e24\u4e2a\u7f3a\u70b9\uff1a<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6d6a\u8d39\u8d44\u6e90\uff1aStudentService\u8c03\u7528\u65b9\u6cd5\u65f6\u5373\u4f1a\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5982\u679c\u4e0d\u65ad\u8c03\u7528\u65b9\u6cd5\u5219\u4f1a\u521b\u5efa\u5927\u91cfStudentDao\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u4ee3\u7801\u8026\u5408\u5ea6\u9ad8\uff1a\u5047\u8bbe\u968f\u7740\u5f00\u53d1\uff0c\u6211\u4eec\u521b\u5efa\u4e86StudentDao\u53e6\u4e00\u4e2a\u66f4\u52a0\u5b8c\u5584\u7684\u5b9e\u73b0\u7c7bStudentDaoImpl2\uff0c\u5982\u679c\u5728StudentService\u4e2d\u60f3\u4f7f\u7528StudentDaoImpl2\uff0c\u5219\u5fc5\u987b\u4fee\u6539\u6e90\u7801\u3002<\/p>\n<\/li>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u800cIOC\u601d\u60f3\u662f\u5c06\u521b\u5efa\u5bf9\u8c61\u7684\u6743\u5229\u4ea4\u7ed9\u6846\u67b6\uff0c\u6846\u67b6\u4f1a\u5e2e\u52a9\u6211\u4eec\u521b\u5efa\u5bf9\u8c61\uff0c\u5206\u914d\u5bf9\u8c61\u7684\u4f7f\u7528\uff0c\u63a7\u5236\u6743\u7531\u7a0b\u5e8f\u4ee3\u7801\u8f6c\u79fb\u5230\u4e86\u6846\u67b6\u4e2d\uff0c\u63a7\u5236\u6743\u53d1\u751f\u4e86\u53cd\u8f6c\uff0c\u8fd9\u5c31\u662fSpring\u7684IOC\u601d\u60f3\u3002\u800cIOC\u601d\u60f3\u53ef\u4ee5\u5b8c\u7f8e\u7684\u89e3\u51b3\u4ee5\u4e0a\u4e24\u4e2a\u95ee\u9898\u3002<\/span><\/span><\/p>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-3\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. IOC\u601d\u60f3\u662f\u5c06\u521b\u5efa\u5bf9\u8c61\u7684\u6743\u5229\u4ea4\u7ed9<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u8c03\u7528\u8005<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u6846\u67b6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u88ab\u8c03\u7528\u8005<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;JDK<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;B<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<h3 id=\"ioc\u81ea\u5b9a\u4e49\u5bf9\u8c61\u5bb9\u5668\" style=\"background-color:transparent\">IOC_\u81ea\u5b9a\u4e49\u5bf9\u8c61\u5bb9\u5668<\/h3>\n<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211124150748998\" height=\"351\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fca4ed44.png\" width=\"925\"><\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u6bb5\u4ee3\u7801\u6a21\u62dfIOC\u601d\u60f3\u3002\u521b\u5efa\u4e00\u4e2a\u96c6\u5408\u5bb9\u5668\uff0c\u5148\u5c06\u5bf9\u8c61\u521b\u5efa\u51fa\u6765\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5bf9\u8c61\u65f6\uff0c\u53ea\u9700\u8981\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61\u5373\u53ef\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u65b0\u521b\u5efa\uff0c\u6b64\u65f6\u5bb9\u5668\u5c31\u662f\u5bf9\u8c61\u7684\u7ba1\u7406\u8005\u3002<\/p>\n<li>\n<p>\u521b\u5efa\u5b9e\u4f53\u7c7b<\/p>\n<p> public class Student {<br \/>\n  private int id;<br \/>\n  private String name;<br \/>\n  private String address;<br \/>\n    \/\/ \u7701\u7565getter\/setter\/\u6784\u9020\u65b9\u6cd5\/tostring<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efaDao\u63a5\u53e3\u548c\u5b9e\u73b0\u7c7b<\/p>\n<p> public interface StudentDao {<br \/>\n  \/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f<br \/>\n  Student findById(int id);<br \/>\n}<\/p>\n<p>public class StudentDaoImpl implements StudentDao {<br \/>\n  @Override<br \/>\n  public Student findById(int id) {<br \/>\n    \/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f<br \/>\n    return new Student(1,\\&#8221;\u767e\u6218\u7a0b\u5e8f\u5458\\&#8221;,\\&#8221;\u5317\u4eac\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<p>public class StudentDaoImpl2 implements StudentDao {<br \/>\n  @Override<br \/>\n  public Student findById(int id) {<br \/>\n    \/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f<br \/>\n    System.out.println(\\&#8221;\u65b0\u65b9\u6cd5\uff01\uff01\uff01\\&#8221;);<br \/>\n    return new Student(1,\\&#8221;\u767e\u6218\u7a0b\u5e8f\u5458\\&#8221;,\\&#8221;\u5317\u4eac\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u914d\u7f6e\u6587\u4ef6bean.properties\uff0c\u8be5\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7ba1\u7406\u7684\u5bf9\u8c61<\/p>\n<p>studentDao=com.itbaizhan.dao.impl.StudentDaoImpl<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u5bb9\u5668\u7ba1\u7406\u7c7b\uff0c\u8be5\u7c7b\u5728\u7c7b\u52a0\u8f7d\u65f6\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u7684\u5bf9\u8c61\u5168\u90e8\u521b\u5efa\u5e76\u653e\u5165\u5bb9\u5668\u4e2d\u3002<\/p>\n<p> public class Container {<br \/>\n  static Map&lt;String,Object&gt; map = new HashMap&lt;&gt;();<br \/>\n  static {<br \/>\n    \/\/ \u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<br \/>\n    InputStream is = Container.class.getClassLoader().getResourceAsStream(\\&#8221;bean.properties\\&#8221;);<br \/>\n    Properties properties = new Properties();<br \/>\n    try {<br \/>\n      properties.load(is);<br \/>\n     } catch (IOException e) {<br \/>\n      throw new RuntimeException(e);<br \/>\n     }<\/p>\n<p>    \/\/ \u904d\u5386\u914d\u7f6e\u6587\u4ef6\u7684\u6240\u6709\u914d\u7f6e\u4fe1\u606f<br \/>\n    Enumeration&lt;Object&gt; keys = properties.keys();<br \/>\n    while (keys.hasMoreElements()){<br \/>\n      String key = keys.nextElement().toString();<br \/>\n      String value = properties.getProperty(key);<br \/>\n      try {<br \/>\n        \/\/ \u521b\u5efa\u5bf9\u8c61\uff0c\u5c06\u5bf9\u8c61\u653e\u5165\u96c6\u5408<br \/>\n        Object o = Class.forName(value).newInstance();<br \/>\n        map.put(key,o);<br \/>\n       } catch (Exception e) {<br \/>\n        e.printStackTrace();<br \/>\n       }<br \/>\n     }<\/p>\n<p>   }<\/p>\n<p>  \/\/ \u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61<br \/>\n  public static Object getBean(String key){<br \/>\n    return map.get(key);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efaDao\u5bf9\u8c61\u7684\u8c03\u7528\u8005StudentService<\/p>\n<p> public class StudentService {<br \/>\n  public Student findStudentById(int id){<br \/>\n    StudentDao studentDao = (StudentDao) Container.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n    System.out.println(studentDao.hashCode());<br \/>\n    return studentDao.findById(id);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u6d4b\u8bd5StudentService<\/p>\n<p> public class Test {<br \/>\n  public static void main(String[] args) {<br \/>\n    StudentService studentService = new StudentService();<br \/>\n    System.out.println(studentService.findStudentById(1));<br \/>\n    System.out.println(studentService.findStudentById(1));<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<li>\n<p>StudentService\u4ece\u5bb9\u5668\u4e2d\u6bcf\u6b21\u62ff\u5230\u7684\u90fd\u662f\u540c\u4e00\u4e2aStudentDao\u5bf9\u8c61\uff0c\u8282\u7ea6\u4e86\u8d44\u6e90\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u60f3\u4f7f\u7528StudentDaoImpl2\u5bf9\u8c61\uff0c\u53ea\u9700\u8981\u4fee\u6539bean.properties\u7684\u5185\u5bb9\u4e3a<\/p>\n<p>studentDao=com.itbaizhan.dao.StudentDaoImpl2<\/p>\n<p>\u5373\u53ef\uff0c\u65e0\u9700\u4fee\u6539Java\u6e90\u7801\u3002<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"346\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fca74f93.png\" width=\"565\"><\/p>\n<\/li>\n<\/p>\n<h3 id=\"iocspring\u5b9e\u73b0ioc\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_Spring\u5b9e\u73b0IOC<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126170010941\" height=\"367\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fca8f7a5.png\" width=\"935\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u63a5\u4e0b\u6765\u6211\u4eec\u4f7f\u7528Spring\u5b9e\u73b0IOC\uff0cSpring\u5185\u90e8\u4e5f\u6709\u4e00\u4e2a\u5bb9\u5668\u7528\u6765\u7ba1\u7406\u5bf9\u8c61\u3002<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u521b\u5efaMaven\u5de5\u7a0b\uff0c\u5f15\u5165\u4f9d\u8d56<\/p>\n<p> &lt;dependencies&gt;<br \/>\n  &lt;dependency&gt;<br \/>\n    &lt;groupId&gt;org.springframework&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spring-context&lt;\/artifactId&gt;<br \/>\n    &lt;version&gt;6.0.11&lt;\/version&gt;<br \/>\n  &lt;\/dependency&gt;<br \/>\n  &lt;dependency&gt;<br \/>\n    &lt;groupId&gt;junit&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;junit&lt;\/artifactId&gt;<br \/>\n    &lt;version&gt;4.12&lt;\/version&gt;<br \/>\n    &lt;scope&gt;test&lt;\/scope&gt;<br \/>\n  &lt;\/dependency&gt;<br \/>\n&lt;\/dependencies&gt;<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u521b\u5efaPOJO\u7c7b\u3001Dao\u7c7b\u548c\u63a5\u53e3<\/p>\n<p> public class Student {<br \/>\n  private int id;<br \/>\n  private String name;<br \/>\n  private String address;<br \/>\n    \/\/ \u7701\u7565getter\/setter\/\u6784\u9020\u65b9\u6cd5\/tostring<br \/>\n}<\/p>\n<p>public interface StudentDao {<br \/>\n  \/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f<br \/>\n  Student findById(int id);<br \/>\n}<\/p>\n<p>public class StudentDaoImpl implements StudentDao{<br \/>\n  @Override<br \/>\n  public Student findById(int id) {<br \/>\n    \/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f<br \/>\n    return new Student(1,\\&#8221;\u767e\u6218\u7a0b\u5e8f\u5458\\&#8221;,\\&#8221;\u5317\u4eac\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u7f16\u5199xml\u914d\u7f6e\u6587\u4ef6\uff0c\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u9700\u8981Spring\u5e2e\u6211\u4eec\u521b\u5efa\u7684\u5bf9\u8c61\u3002<\/p>\n<p> &lt;?xml version=\\&#8221;1.0\\&#8221; encoding=\\&#8221;UTF-8\\&#8221;?&gt;<br \/>\n&lt;beans xmlns=\\&#8221;http:\/\/www.springframework.org\/schema\/beans\\&#8221;<br \/>\n    xmlns:xsi=\\&#8221;http:\/\/www.w3.org\/2001\/XMLSchema-instance\\&#8221;<br \/>\n    xsi:schemaLocation=\\&#8221;http:\/\/www.springframework.org\/schema\/beans<br \/>\n    http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\\&#8221;&gt;<\/p>\n<p>  &lt;bean id=\\&#8221;studentDao\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoImpl\\&#8221;&gt;&lt;\/bean&gt;<\/p>\n<p>&lt;\/beans&gt;<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6d4b\u8bd5\u4eceSpring\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61\u3002<\/p>\n<p> public class TestContainer {<br \/>\n  @Test<br \/>\n  public void t1(){<br \/>\n    \/\/ \u521b\u5efaSpring\u5bb9\u5668<br \/>\n    ApplicationContext ac = new ClassPathXmlApplicationContext(\\&#8221;bean.xml\\&#8221;);<br \/>\n    \/\/ \u4ece\u5bb9\u5668\u83b7\u53d6\u5bf9\u8c61<br \/>\n    StudentDao studentDao1 = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n    StudentDao studentDao2 = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n    System.out.println(studentDao1.hashCode());<br \/>\n    System.out.println(studentDao2.hashCode());<br \/>\n    System.out.println(studentDao1.findById(1));<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-4\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u901a\u8fc7\u914d\u7f6e\u6807\u7b7e\u914d\u7f6e\u5bb9\u5668\u4e2d\u7684\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;&lt;beans&gt;<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;&lt;pojo&gt;<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;&lt;entity&gt;<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;&lt;bean&gt;<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. Spring\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c&lt;bean&gt;\u6807\u7b7e\u7684\u5c5e\u6027\u53ef\u4ee5\u914d\u7f6e\u5bf9\u8c61\u7c7b\u578b<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;id<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;name<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;class<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;value<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;D&nbsp;2=&gt;C<\/span><\/span><\/p>\n<\/p>\n<h3 id=\"iocspring\u5bb9\u5668\u7c7b\u578b\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_Spring\u5bb9\u5668\u7c7b\u578b<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211124165406979\" height=\"363\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fcab9df8.png\" width=\"500\"><\/p>\n<h4 id=\"\u5bb9\u5668\u63a5\u53e3\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5bb9\u5668\u63a5\u53e3<\/span><\/span><\/h4>\n<ul style=\"margin-left:.8em;margin-right:.8em\">\n<li>\n<p style=\"margin-left:0;margin-right:0\">BeanFactory\uff1aBeanFactory\u662fSpring\u5bb9\u5668\u4e2d\u7684\u9876\u5c42\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u5bf9Bean\u5bf9\u8c61\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">ApplicationContext\uff1aApplicationContext\u662fBeanFactory\u7684\u5b50\u63a5\u53e3\u3002\u5b83\u9664\u4e86\u7ee7\u627f BeanFactory\u7684\u6240\u6709\u529f\u80fd\u5916\uff0c\u8fd8\u6dfb\u52a0\u4e86\u5bf9\u56fd\u9645\u5316\u3001\u8d44\u6e90\u8bbf\u95ee\u3001\u4e8b\u4ef6\u4f20\u64ad\u7b49\u65b9\u9762\u7684\u826f\u597d\u652f\u6301\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0\">ApplicationContext\u6709\u4ee5\u4e0b\u4e09\u4e2a\u5e38\u7528\u5b9e\u73b0\u7c7b\uff1a<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"\u5bb9\u5668\u5b9e\u73b0\u7c7b\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5bb9\u5668\u5b9e\u73b0\u7c7b<\/span><\/span><\/h4>\n<ul style=\"margin-left:.8em;margin-right:.8em\">\n<li>\n<p style=\"margin-left:0;margin-right:0\">ClassPathXmlApplicationContext\uff1a\u8be5\u7c7b\u53ef\u4ee5\u4ece\u9879\u76ee\u4e2d\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">FileSystemXmlApplicationContext\uff1a\u8be5\u7c7b\u4ece\u78c1\u76d8\u4e2d\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">AnnotationConfigApplicationContext\uff1a\u4f7f\u7528\u8be5\u7c7b\u4e0d\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6\uff0c\u800c\u662f\u4f1a\u8bfb\u53d6\u6ce8\u89e3<\/p>\n<\/li>\n<\/ul>\n<p>@Test<br \/>\npublic void t2(){<br \/>\n  \/\/ \u521b\u5efaspring\u5bb9\u5668<br \/>\n  \/\/     ApplicationContext ac = new ClassPathXmlApplicationContext(\\&#8221;bean.xml\\&#8221;);<br \/>\n  ApplicationContext ac = new FileSystemXmlApplicationContext(\\&#8221;C:\\\\\\\\Users\\\\\\\\a\\\\\\\\IdeaProjects\\\\\\\\spring_demo\\\\\\\\src\\\\\\\\main\\\\\\\\resources\\\\\\\\bean.xml\\&#8221;);<\/p>\n<p>  \/\/ \u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61<br \/>\n  StudentDao userDao = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n  System.out.println(userDao);<br \/>\n  System.out.println(userDao.findById(1));<br \/>\n}<\/p>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-5\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u5bb9\u5668\u7684\u9876\u5c42\u63a5\u53e3\u662f<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;BeanFactory<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;ApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;ClassPathXmlApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;FileSystemXmlApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. \u5982\u679c\u60f3\u4ece\u78c1\u76d8\u4e2d\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6\uff0c\u9700\u8981\u521b\u5efa\u7c7b\u578b\u7684Spring\u5bb9\u5668<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;ClassPathXmlApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;FileSystemXmlApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;AnnotationConfigApplicationContext<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u4ee5\u4e0a\u90fd\u53ef\u4ee5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;A&nbsp;2=&gt;B<\/span><\/span><\/p>\n<\/p>\n<\/p>\n<\/p>\n<h3 id=\"ioc\u5bf9\u8c61\u7684\u521b\u5efa\u65b9\u5f0f\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u5bf9\u8c61\u7684\u521b\u5efa\u65b9\u5f0f<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126171348088\" height=\"602\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131450-689c8fcad6a9b.png\" width=\"462\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u4f1a\u5e2e\u52a9\u6211\u4eec\u521b\u5efabean\uff0c\u90a3\u4e48\u5b83\u5e95\u5c42\u662f\u8c03\u7528\u4ec0\u4e48\u65b9\u6cd5\u8fdb\u884c\u521b\u5efa\u7684\u5462\uff1f<\/span><\/span><\/p>\n<h4 id=\"\u4f7f\u7528\u6784\u9020\u65b9\u6cd5\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u4f7f\u7528\u6784\u9020\u65b9\u6cd5<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u9ed8\u8ba4\u4f7f\u7528\u7c7b\u7684\u7a7a\u53c2\u6784\u9020\u65b9\u6cd5\u521b\u5efabean\uff1a<\/span><\/span><\/p>\n<p>\/\/ \u5047\u5982\u7c7b\u6ca1\u6709\u7a7a\u53c2\u6784\u9020\u65b9\u6cd5\uff0c\u5c06\u65e0\u6cd5\u5b8c\u6210bean\u7684\u521b\u5efa<br \/>\npublic class StudentDaoImpl implements StudentDao{<br \/>\n  public StudentDaoImpl(int a){}<\/p>\n<p>  @Override<br \/>\n  public Student findById(int id) {<br \/>\n    \/\/ \u6a21\u62df\u6839\u636eid\u67e5\u8be2\u5b66\u751f<br \/>\n    return new Student(1,\\&#8221;\u767e\u6218\u7a0b\u5e8f\u5458\\&#8221;,\\&#8221;\u5317\u4eac\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<h4 id=\"\u4f7f\u7528\u5de5\u5382\u7c7b\u7684\u65b9\u6cd5\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u4f7f\u7528\u5de5\u5382\u7c7b\u7684\u65b9\u6cd5<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u53ef\u4ee5\u8c03\u7528\u5de5\u5382\u7c7b\u7684\u65b9\u6cd5\u521b\u5efabean\uff1a<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u521b\u5efa\u5de5\u5382\u7c7b\uff0c\u5de5\u5382\u7c7b\u63d0\u4f9b\u521b\u5efa\u5bf9\u8c61\u7684\u65b9\u6cd5\uff1a<\/p>\n<p> public class StudentDaoFactory {<br \/>\n  public StudentDao getStudentDao(){<br \/>\n    return new StudentDaoImpl(1);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u521b\u5efabean\u7684\u65b9\u5f0f\u4e3a\u5de5\u5382\u65b9\u5f0f\u3002<\/p>\n<p> &lt;!&#8211;  id\uff1a\u5de5\u5382\u5bf9\u8c61\u7684id\uff0cclass\uff1a\u5de5\u5382\u7c7b  &#8211;&gt;<br \/>\n&lt;bean id=\\&#8221;studentDaoFactory\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoFactory\\&#8221;&gt;&lt;\/bean&gt;<br \/>\n&lt;!&#8211;  id\uff1abean\u5bf9\u8c61\u7684id\uff0cfactory-bean\uff1a\u5de5\u5382\u5bf9\u8c61\u7684id\uff0cfactory-method\uff1a\u5de5\u5382\u65b9\u6cd5 &#8211;&gt;<br \/>\n&lt;bean id=\\&#8221;studentDao\\&#8221; factory-bean=\\&#8221;studentDaoFactory\\&#8221; factory-method=\\&#8221;getStudentDao\\&#8221;&gt;&lt;\/bean&gt;<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6d4b\u8bd5<\/p>\n<\/li>\n<h4 id=\"\u4f7f\u7528\u5de5\u5382\u7c7b\u7684\u9759\u6001\u65b9\u6cd5\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u4f7f\u7528\u5de5\u5382\u7c7b\u7684\u9759\u6001\u65b9\u6cd5<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u53ef\u4ee5\u8c03\u7528\u5de5\u5382\u7c7b\u7684\u9759\u6001\u65b9\u6cd5\u521b\u5efabean\uff1a<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u521b\u5efa\u5de5\u5382\u7c7b\uff0c\u5de5\u5382\u63d0\u4f9b\u521b\u5efa\u5bf9\u8c61\u7684\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n<p> public class StudentDaoFactory2 {<br \/>\n  public static StudentDao getStudentDao2() {<br \/>\n    return new StudentDaoImpl();<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u521b\u5efabean\u7684\u65b9\u5f0f\u4e3a\u5de5\u5382\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n<p> &lt;!&#8211; id:bean\u7684id  class:\u5de5\u5382\u5168\u7c7b\u540d factory-method:\u5de5\u5382\u9759\u6001\u65b9\u6cd5  &#8211;&gt;<br \/>\n&lt;bean id=\\&#8221;studentDao\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoFactory2\\&#8221; factory-method=\\&#8221;getStudentDao2\\&#8221;&gt;&lt;\/bean&gt;<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6d4b\u8bd5<\/p>\n<\/li>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-6\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u4e0d\u80fd\u4f7f\u7528\u521b\u5efabean\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u9759\u6001\u5de5\u5382\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u5de5\u5382\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u7a7a\u53c2\u6784\u9020\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u6709\u53c2\u6784\u9020\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. Spring\u8c03\u7528\u5de5\u5382\u7c7b\u7684\u666e\u901a\u65b9\u6cd5\u521b\u5efabean\u9700\u8981\u914d\u7f6e<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u5de5\u5382\u5bf9\u8c61\u548c\u88ab\u521b\u5efa\u7684\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u5de5\u5382\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u88ab\u521b\u5efa\u7684\u5bf9\u8c61<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u4ee5\u4e0a\u90fd\u53ef\u4ee5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;C&nbsp;2=&gt;A<\/span><\/span><\/p>\n<\/p>\n<\/p>\n<h3 id=\"ioc\u5bf9\u8c61\u7684\u521b\u5efa\u7b56\u7565\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u5bf9\u8c61\u7684\u521b\u5efa\u7b56\u7565<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126171610772\" height=\"406\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131451-689c8fcb085d3.png\" width=\"564\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u901a\u8fc7\u914d\u7f6e&lt;bean&gt;\u4e2d\u7684scope\u5c5e\u6027\u8bbe\u7f6e\u5bf9\u8c61\u7684\u521b\u5efa\u7b56\u7565\uff0c\u5171\u6709\u4e94\u79cd\u521b\u5efa\u7b56\u7565\uff1a<\/span><\/span><\/p>\n<ul style=\"margin-left:.8em;margin-right:.8em\">\n<li>\n<p style=\"margin-left:0;margin-right:0\">singleton\uff1a\u5355\u4f8b\uff0c\u9ed8\u8ba4\u7b56\u7565\u3002\u6574\u4e2a\u9879\u76ee\u53ea\u4f1a\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u901a\u8fc7&lt;bean&gt;\u4e2d\u7684lazy-init\u5c5e\u6027\u53ef\u4ee5\u8bbe\u7f6e\u5355\u4f8b\u5bf9\u8c61\u7684\u521b\u5efa\u65f6\u673a\uff1a<\/p>\n<p style=\"margin-left:0;margin-right:0\">lazy-init=\\&#8221;false\\&#8221;(\u9ed8\u8ba4)\uff1a\u7acb\u5373\u521b\u5efa\uff0c\u5728\u5bb9\u5668\u542f\u52a8\u65f6\u4f1a\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u6240\u6709Bean\u5bf9\u8c61\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0\">lazy-init=\\&#8221;true\\&#8221;\uff1a\u5ef6\u8fdf\u521b\u5efa\uff0c\u7b2c\u4e00\u6b21\u4f7f\u7528Bean\u5bf9\u8c61\u65f6\u624d\u4f1a\u521b\u5efa\u3002<\/p>\n<p style=\"margin-left:0;margin-right:0\">\u914d\u7f6e\u5355\u4f8b\u7b56\u7565\uff1a<\/p>\n<p> &lt;!&#8211; &lt;bean id=\\&#8221;studentDao\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221; scope=\\&#8221;singleton\\&#8221; lazy-init=\\&#8221;true\\&#8221;&gt;&lt;\/bean&gt; &#8211;&gt;<br \/>\n&lt;bean id=\\&#8221;studentDao\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221; scope=\\&#8221;singleton\\&#8221; lazy-init=\\&#8221;false\\&#8221;&gt;&lt;\/bean&gt;<\/p>\n<p style=\"margin-left:0;margin-right:0\">\u6d4b\u8bd5\u5355\u4f8b\u7b56\u7565\uff1a<\/p>\n<p> \/\/ \u4e3aBean\u5bf9\u8c61\u7684\u7c7b\u6dfb\u52a0\u6784\u9020\u65b9\u6cd5<br \/>\npublic StudentDaoImpl2(){<br \/>\n  System.out.println(\\&#8221;\u521b\u5efaStudentDao\uff01\uff01\uff01\\&#8221;);<br \/>\n}<\/p>\n<p>@Test<br \/>\npublic void t2(){<br \/>\n  \/\/ \u521b\u5efaSpring\u5bb9\u5668<br \/>\n  ApplicationContext ac = new ClassPathXmlApplicationContext(\\&#8221;bean1.xml\\&#8221;);<br \/>\n  \/\/ \u4ece\u5bb9\u5668\u83b7\u53d6\u5bf9\u8c61<br \/>\n  StudentDao studentDao1 = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n  StudentDao studentDao2 = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n  StudentDao studentDao3 = (StudentDao) ac.getBean(\\&#8221;studentDao\\&#8221;);<br \/>\n  System.out.println(studentDao1.hashCode());<br \/>\n  System.out.println(studentDao2.hashCode());<br \/>\n  System.out.println(studentDao3.hashCode());<br \/>\n}<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">prototype\uff1a\u591a\u4f8b\uff0c\u6bcf\u6b21\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u65f6\u90fd\u4f1a\u521b\u5efa\u5bf9\u8c61\u3002<\/p>\n<p>             <span style=\"color:#aa5500\">&lt;!&#8211; \u914d\u7f6e\u591a\u4f8b\u7b56\u7565 &#8211;&gt;<\/span> <\/p>\n<p>            <span style=\"color:#117700\">&lt;<\/span><br \/>\n            <span style=\"color:#117700\">bean<\/span><br \/>\n            <span style=\"color:#0000cc\">id<\/span>=<br \/>\n            <span style=\"color:#aa1111\">\\&#8221;studentDao\\&#8221;<\/span><br \/>\n            <span style=\"color:#0000cc\">class<\/span>=<br \/>\n            <span style=\"color:#aa1111\">\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221;<\/span><br \/>\n            <span style=\"color:#0000cc\">scope<\/span>=<br \/>\n            <span style=\"color:#aa1111\">\\&#8221;prototype\\&#8221;<\/span><br \/>\n            <span style=\"color:#117700\">&gt;&lt;\/<\/span><br \/>\n            <span style=\"color:#117700\">bean<\/span><br \/>\n            <span style=\"color:#117700\">&gt;<\/span> <\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">request\uff1a\u6bcf\u6b21\u8bf7\u6c42\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ea\u5728web\u73af\u5883\u6709\u6548\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">session\uff1a\u6bcf\u6b21\u4f1a\u8bdd\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ea\u5728web\u73af\u5883\u6709\u6548\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">gloabal-session\uff1a\u4e00\u6b21\u96c6\u7fa4\u73af\u5883\u7684\u4f1a\u8bdd\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ea\u5728web\u73af\u5883\u6709\u6548\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-7\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. Spring\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c&lt;bean&gt;\u4e2d\u7684scope\u5c5e\u6027\u503c\u4e3a\u8868\u793a\u8be5\u5bf9\u8c61\u662f\u5355\u4f8b\u7684<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;singleton<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;prototype<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;request<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;session<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. Spring\u5355\u4f8b\u5bf9\u8c61\u8bbe\u7f6elazy-init=\\&#8221;false\\&#8221;\u8868\u793a\u5b83\u7684\u521b\u5efa\u65f6\u673a\u4e3a<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u7b2c\u4e00\u6b21\u4f7f\u7528\u5bf9\u8c61\u65f6\u521b\u5efa<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u6bcf\u6b21\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u65f6\u90fd\u4f1a\u521b\u5efa<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u5728\u5bb9\u5668\u542f\u52a8\u65f6\u4f1a\u521b\u5efa<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u6bcf\u6b21\u8bf7\u6c42\u65f6\u521b\u5efa<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;A&nbsp;2=&gt;C<\/span><\/span><\/p>\n<\/p>\n<\/p>\n<h3 id=\"ioc\u5bf9\u8c61\u7684\u9500\u6bc1\u65f6\u673a\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u5bf9\u8c61\u7684\u9500\u6bc1\u65f6\u673a<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126171718292\" height=\"586\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131451-689c8fcb219eb.png\" width=\"651\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5bf9\u8c61\u7684\u521b\u5efa\u7b56\u7565\u4e0d\u540c\uff0c\u9500\u6bc1\u65f6\u673a\u4e5f\u4e0d\u540c\uff1a<\/span><\/span><\/p>\n<ul style=\"margin-left:.8em;margin-right:.8em\">\n<li>singleton\uff1a\u5bf9\u8c61\u968f\u7740\u5bb9\u5668\u7684\u9500\u6bc1\u800c\u9500\u6bc1\u3002<\/li>\n<li>prototype\uff1a\u4f7f\u7528JAVA\u5783\u573e\u56de\u6536\u673a\u5236\u9500\u6bc1\u5bf9\u8c61\u3002<\/li>\n<li>request\uff1a\u5f53\u5904\u7406\u8bf7\u6c42\u7ed3\u675f\uff0cbean\u5b9e\u4f8b\u5c06\u88ab\u9500\u6bc1\u3002<\/li>\n<li>session\uff1a\u5f53HTTP Session\u6700\u7ec8\u88ab\u5e9f\u5f03\u7684\u65f6\u5019\uff0cbean\u4e5f\u4f1a\u88ab\u9500\u6bc1\u6389\u3002<\/li>\n<li>gloabal-session\uff1a\u96c6\u7fa4\u73af\u5883\u4e0b\u7684session\u9500\u6bc1\uff0cbean\u5b9e\u4f8b\u4e5f\u5c06\u88ab\u9500\u6bc1\u3002<\/li>\n<\/ul>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<h4 id=\"\u5b9e\u65f6\u5b66\u4e60\u53cd\u9988-1\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u5b66\u4e60\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. \u5728Spring\u4e2d\uff0c\u5355\u4f8b\u5bf9\u8c61\u9500\u6bc1<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u5728\u670d\u52a1\u5668\u5173\u95ed\u65f6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u4f7f\u7528JAVA\u5783\u573e\u56de\u6536\u673a\u5236<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u5bb9\u5668\u9500\u6bc1\u65f6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. \u5728Spring\u4e2d\uff0c\u591a\u4f8b\u5bf9\u8c61\u9500\u6bc1<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;\u5728\u670d\u52a1\u5668\u5173\u95ed\u65f6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;\u4f7f\u7528JAVA\u5783\u573e\u56de\u6536\u673a\u5236<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;\u5bb9\u5668\u9500\u6bc1\u65f6<\/span><\/span><\/p>\n<h4 id=\"\u7b54\u6848-1\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;D&nbsp;2=&gt;B<\/span><\/span><\/p>\n<\/p>\n<h3 id=\"ioc\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126174228461\" height=\"568\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131451-689c8fcb80176.png\" width=\"772\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Bean\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\u5305\u542b\u521b\u5efa\u2014\u2014\u4f7f\u7528\u2014\u2014\u9500\u6bc1\uff0cSpring\u53ef\u4ee5\u914d\u7f6eBean\u5bf9\u8c61\u5728\u521b\u5efa\u548c\u9500\u6bc1\u65f6\u81ea\u52a8\u6267\u884c\u7684\u65b9\u6cd5\uff1a<\/span><\/span><\/p>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u5b9a\u4e49\u751f\u547d\u5468\u671f\u65b9\u6cd5<\/p>\n<p> public class StudentDaoImpl2 implements StudentDao{<br \/>\n  \/\/ \u521b\u5efa\u65f6\u81ea\u52a8\u6267\u884c\u7684\u65b9\u6cd5<br \/>\n  public void init(){<br \/>\n    System.out.println(\\&#8221;\u521b\u5efaStudentDao\uff01\uff01\uff01\\&#8221;);<br \/>\n   }<\/p>\n<p>  \/\/ \u9500\u6bc1\u65f6\u81ea\u52a8\u6267\u884c\u7684\u65b9\u6cd5<br \/>\n  public void destory(){<br \/>\n    System.out.println(\\&#8221;\u9500\u6bc1StudentDao\uff01\uff01\uff01\\&#8221;);<br \/>\n   }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u914d\u7f6e\u751f\u547d\u5468\u671f\u65b9\u6cd5<\/p>\n<p> &lt;!&#8211; init-method:\u521b\u5efa\u5bf9\u8c61\u65f6\u6267\u884c\u7684\u65b9\u6cd5  destroy-method:\u9500\u6bc1\u5bf9\u8c61\u65f6\u6267\u884c\u7684\u65b9\u6cd5  &#8211;&gt;<br \/>\n&lt;bean id=\\&#8221;studentDao\\&#8221; class=\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221; scope=\\&#8221;singleton\\&#8221;<br \/>\n   init-method=\\&#8221;init\\&#8221; destroy-method=\\&#8221;destory\\&#8221;&gt;&lt;\/bean&gt;<\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u6d4b\u8bd5<\/p>\n<p> @Test<br \/>\npublic void t3(){<br \/>\n  \/\/ \u521b\u5efaSpring\u5bb9\u5668<br \/>\n  ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext(\\&#8221;bean1.xml\\&#8221;);<\/p>\n<p>  \/\/ \u9500\u6bc1Spring\u5bb9\u5668\uff0cClassPathXmlApplicationContext\u624d\u6709\u9500\u6bc1\u5bb9\u5668\u7684\u65b9\u6cd5<br \/>\n  ac.close();<br \/>\n}<\/p>\n<\/li>\n<h4 id=\"\u5b9e\u65f6\u6548\u679c\u53cd\u9988-8\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u5b9e\u65f6\u6548\u679c\u53cd\u9988<\/span><\/span><\/h4>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1. \u5728Spring\u4e2d\uff0c&lt;bean&gt;\u4e2d\u914d\u7f6e\u5c5e\u6027\u53ef\u4ee5\u5b9a\u4e49\u521b\u5efa\u5bf9\u8c61\u65f6\u6267\u884c\u7684\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;id<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;init-method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;destroy-method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">2. \u5728Spring\u4e2d\uff0c&lt;bean&gt;\u4e2d\u914d\u7f6e\u5c5e\u6027\u53ef\u4ee5\u5b9a\u4e49\u9500\u6bc1\u5bf9\u8c61\u65f6\u6267\u884c\u7684\u65b9\u6cd5<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">A&nbsp;id<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">B&nbsp;method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">C&nbsp;init-method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">D&nbsp;destroy-method<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u7b54\u6848<\/span><\/span><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">1=&gt;C&nbsp;2=&gt;D<\/span><\/span><\/p>\n<\/p>\n<\/p>\n<h3 id=\"ioc\u83b7\u53d6\u5bf9\u8c61\u7684\u65b9\u5f0f\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">IOC_\u83b7\u53d6\u5bf9\u8c61\u7684\u65b9\u5f0f<\/span><\/span><\/h3>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"image-20211126174452548\" height=\"510\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131451-689c8fcbea427.png\" width=\"457\"><\/p>\n<p style=\"margin-left:.8em;margin-right:.8em;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">Spring\u6709\u591a\u79cd\u83b7\u53d6\u5bb9\u5668\u4e2d\u5bf9\u8c61\u7684\u65b9\u5f0f\uff1a<\/span><\/span><\/p>\n<h4 id=\"\u901a\u8fc7idname\u83b7\u53d6\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u901a\u8fc7id\/name\u83b7\u53d6<\/span><\/span><\/h4>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>             <span style=\"color:#117700\">&lt;<\/span><br \/>\n             <span style=\"color:#117700\">bean<\/span><br \/>\n             <span style=\"color:#0000cc\">name<\/span>=<br \/>\n             <span style=\"color:#aa1111\">\\&#8221;studentDao\\&#8221;<\/span><br \/>\n             <span style=\"color:#0000cc\">class<\/span>=<br \/>\n             <span style=\"color:#aa1111\">\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221;<\/span><br \/>\n             <span style=\"color:#117700\">&gt;&lt;\/<\/span><br \/>\n             <span style=\"color:#117700\">bean<\/span><br \/>\n             <span style=\"color:#117700\">&gt;<\/span> <\/p>\n<p>            <span style=\"color:#117700\">&lt;<\/span><br \/>\n            <span style=\"color:#117700\">bean<\/span><br \/>\n            <span style=\"color:#0000cc\">id<\/span>=<br \/>\n            <span style=\"color:#aa1111\">\\&#8221;studentDao\\&#8221;<\/span><br \/>\n            <span style=\"color:#0000cc\">class<\/span>=<br \/>\n            <span style=\"color:#aa1111\">\\&#8221;com.itbaizhan.dao.StudentDaoImpl2\\&#8221;<\/span><br \/>\n            <span style=\"color:#117700\">&gt;&lt;\/<\/span><br \/>\n            <span style=\"color:#117700\">bean<\/span><br \/>\n            <span style=\"color:#117700\">&gt;<\/span> <\/p>\n<\/li>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u83b7\u53d6\u5bf9\u8c61<\/p>\n<p>             <span style=\"color:#000000\">StudentDao<\/span><br \/>\n             <span style=\"color:#000000\">studentDao<\/span><br \/>\n             <span style=\"color:#981a1a\">=<\/span> (<br \/>\n             <span style=\"color:#000000\">StudentDao<\/span>)<br \/>\n             <span style=\"color:#000000\">ac<\/span>.<br \/>\n             <span style=\"color:#000000\">getBean<\/span>(<br \/>\n             <span style=\"color:#aa1111\">\\&#8221;studentDao\\&#8221;<\/span>); <\/p>\n<\/li>\n<h4 id=\"\u901a\u8fc7\u7c7b\u578b\u83b7\u53d6\" style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#333333\"><span style=\"background-color:#ffffff\">\u901a\u8fc7\u7c7b\u578b\u83b7\u53d6<\/span><\/span><\/h4>\n<li>\n<p style=\"margin-left:0;margin-right:0\">\u914d\u7f6e\u6587\u4ef6<\/p>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb534\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u6bb5\u4ee3\u7801\u6a21\u62dfIOC\u601d\u60f3\u3002\u521b\u5efa\u4e00\u4e2a\u96c6\u5408\u5bb9\u5668\uff0c\u5148\u5c06\u5bf9\u8c61\u521b\u5efa\u51fa\u6765\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5bf9\u8c61\u65f6\uff0c\u53ea\u9700\u8981\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61\u5373\u53ef\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u65b0\u521b\u5efa\uff0c\u6b64\u65f6\u5bb9\u5668\u5c31\u662f\u5bf9\u8c61\u7684\u7ba1\u7406\u8005\u3002\u521b\u5efa\u5b9e\u4f53\u7c7b\/\/ \u7701\u7565getter\/setter\/\u6784\u9020\u65b9\u6cd5\/tostring\u521b\u5efaDao\u63a5\u53e3\u548c\u5b9e\u73b0\u7c7b\/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751freturn new Student(1,&quot;\u767e\u6218\u7a0b\u5e8f\u5458&quot;,&quot;\u5317\u4eac&quot;);@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f\u3002<\/p>\n","protected":false},"author":2,"featured_media":55349,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,101,292,5692],"topic":[],"class_list":["post-55361","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-spring","tag-292","tag-ssm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \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\/55361.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb534\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u6bb5\u4ee3\u7801\u6a21\u62dfIOC\u601d\u60f3\u3002\u521b\u5efa\u4e00\u4e2a\u96c6\u5408\u5bb9\u5668\uff0c\u5148\u5c06\u5bf9\u8c61\u521b\u5efa\u51fa\u6765\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5bf9\u8c61\u65f6\uff0c\u53ea\u9700\u8981\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61\u5373\u53ef\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u65b0\u521b\u5efa\uff0c\u6b64\u65f6\u5bb9\u5668\u5c31\u662f\u5bf9\u8c61\u7684\u7ba1\u7406\u8005\u3002\u521b\u5efa\u5b9e\u4f53\u7c7b\/\/ \u7701\u7565getter\/setter\/\u6784\u9020\u65b9\u6cd5\/tostring\u521b\u5efaDao\u63a5\u53e3\u548c\u5b9e\u73b0\u7c7b\/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751freturn new Student(1,&quot;\u767e\u6218\u7a0b\u5e8f\u5458&quot;,&quot;\u5317\u4eac&quot;);@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/55361.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-13T13:14:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131449-689c8fc91f59e.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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55361.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/55361.html\",\"name\":\"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-13T13:14:53+00:00\",\"dateModified\":\"2025-08-13T13:14:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/55361.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/55361.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55361.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf\"}]},{\"@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":"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \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\/55361.html","og_locale":"zh_CN","og_type":"article","og_title":"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb534\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u6bb5\u4ee3\u7801\u6a21\u62dfIOC\u601d\u60f3\u3002\u521b\u5efa\u4e00\u4e2a\u96c6\u5408\u5bb9\u5668\uff0c\u5148\u5c06\u5bf9\u8c61\u521b\u5efa\u51fa\u6765\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u5bf9\u8c61\u65f6\uff0c\u53ea\u9700\u8981\u4ece\u5bb9\u5668\u4e2d\u83b7\u53d6\u5bf9\u8c61\u5373\u53ef\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u65b0\u521b\u5efa\uff0c\u6b64\u65f6\u5bb9\u5668\u5c31\u662f\u5bf9\u8c61\u7684\u7ba1\u7406\u8005\u3002\u521b\u5efa\u5b9e\u4f53\u7c7b\/\/ \u7701\u7565getter\/setter\/\u6784\u9020\u65b9\u6cd5\/tostring\u521b\u5efaDao\u63a5\u53e3\u548c\u5b9e\u73b0\u7c7b\/\/ \u6839\u636eid\u67e5\u8be2\u5b66\u751f@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751freturn new Student(1,&quot;\u767e\u6218\u7a0b\u5e8f\u5458&quot;,&quot;\u5317\u4eac&quot;);@Override\/\/ \u6a21\u62df\u4ece\u6570\u636e\u5e93\u67e5\u627e\u51fa\u5b66\u751f\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/55361.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-13T13:14:53+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813131449-689c8fc91f59e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/55361.html","url":"https:\/\/www.wsisp.com\/helps\/55361.html","name":"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-13T13:14:53+00:00","dateModified":"2025-08-13T13:14:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/55361.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/55361.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/55361.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Spring\uff08\u5168\u7f51\u6700\u8be6\u7ec6\uff09\u503c\u5f97\u6536\u85cf"}]},{"@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\/55361","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=55361"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55361\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/55349"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=55361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=55361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=55361"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=55361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}