{"id":89111,"date":"2026-08-02T13:08:25","date_gmt":"2026-08-02T05:08:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/89111.html"},"modified":"2026-08-02T13:08:25","modified_gmt":"2026-08-02T05:08:25","slug":"%e9%80%9a%e4%bf%97%e6%8b%86%e8%a7%a3spring-ioc-di%e4%b8%89%e5%b1%82%e8%b0%83%e7%94%a8%e5%85%a8%e6%b5%81%e7%a8%8b%ef%bd%9c%e8%8b%8d%e7%a9%b9%e5%a4%96%e5%8d%96day2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/89111.html","title":{"rendered":"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u5b66\u4e60\u82cd\u7a79\u5916\u5356\u7b2c 2 \u5929\u3002\u4eca\u5929\u4e0d\u6ee1\u8db3\u4e8e &#034;\u4ee3\u7801\u80fd\u8dd1\u5c31\u884c&#034;&#xff0c;\u6211\u51b3\u5b9a\u5f7b\u5e95\u641e\u6e05\u695a Spring \u6700\u6838\u5fc3\u7684\u4e24\u4e2a\u6982\u5ff5&#xff1a;IoC&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09; \u548c DI&#xff08;\u4f9d\u8d56\u6ce8\u5165&#xff09;\u3002\u7136\u540e\u7528\u4e00\u4e2a\u771f\u5b9e\u7684\u63a5\u53e3&#xff0c;\u628a Controller \u2192 Service \u2192 Mapper \u7684\u5b8c\u6574\u8c03\u7528\u94fe\u8d70\u4e00\u904d\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4f20\u7edf\u65b9\u5f0f&#xff1a;\u6211\u81ea\u5df1\u62db\u4eba\u5e72\u6d3b<\/h3>\n<p>\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u6ca1\u6709 Spring \u6846\u67b6&#xff0c;\u6211\u8981\u5f00\u4e00\u5bb6\u9910\u5385\u3002\u6211\u662f\u8001\u677f&#xff08;Service&#xff09;&#xff0c;\u9700\u8981\u4e00\u4e2a\u5207\u83dc\u5de5&#xff08;Mapper&#xff09;\u6765\u5e72\u6d3b\u3002<\/p>\n<p>\u6211\u53ea\u80fd\u81ea\u5df1\u53bb\u62db\u4eba&#xff1a;<\/p>\n<p>public class EmployeeServiceImpl {<br \/>\n    \/\/ \u6211\u81ea\u5df1\u8d1f\u8d23&#034;\u627e&#034;\u548c&#034;\u521b\u5efa&#034;\u8fd9\u4e2a\u5207\u83dc\u5de5<br \/>\n    private EmployeeMapper employeeMapper &#061; new EmployeeMapperImpl(); <\/p>\n<p>    public void login() {<br \/>\n        employeeMapper.getByUsername(&#8230;); \/\/ \u7136\u540e\u624d\u80fd\u7528\u4ed6<br \/>\n    }<br \/>\n}<\/p>\n<p>\u8fd9\u4e48\u505a\u7684\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5f3a\u4f9d\u8d56&#xff1a;\u5fc5\u987b\u7cbe\u786e\u77e5\u9053\u53bb\u54ea\u627e\u5207\u83dc\u5de5&#xff08;EmployeeMapperImpl&#xff09;&#xff0c;\u5b9e\u73b0\u7c7b\u53d8\u66f4&#xff0c;\u4ee3\u7801\u5fc5\u987b\u4fee\u6539<\/li>\n<li>\u804c\u8d23\u4e0d\u6e05&#xff1a;\u65e2\u8981\u5199\u4e1a\u52a1\u903b\u8f91&#xff0c;\u53c8\u8981\u8d1f\u8d23\u5bf9\u8c61\u521b\u5efa&#xff0c;\u5173\u6ce8\u70b9\u6df7\u4e71<\/li>\n<li>\u6d6a\u8d39\u8d44\u6e90&#xff1a;\u591a\u4e2a Service \u4f9d\u8d56\u540c\u4e00\u4e2a Mapper&#xff0c;\u9700\u91cd\u590d\u521b\u5efa\u5bf9\u8c61&#xff0c;\u65e0\u6cd5\u590d\u7528<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001Spring \u65b9\u5f0f&#xff1a;\u4e2d\u4ecb\u516c\u53f8\u5305\u529e\u4e00\u5207<\/h3>\n<p>Spring \u6846\u67b6\u5f00\u4e86\u4e00\u5bb6\u5f3a\u5927\u7684 &#034;\u4e2d\u4ecb\u516c\u53f8&#034;&#xff0c;\u5b66\u540d\u53eb\u505a IoC \u5bb9\u5668&#xff08;\u63a7\u5236\u53cd\u8f6c\u5bb9\u5668&#xff09;\u3002<\/p>\n<h4>\u6838\u5fc3\u6982\u5ff5<\/h4>\n<ul>\n<li>\u63a7\u5236\u53cd\u8f6c&#xff08;IoC&#xff09;&#xff1a;\u628a &#034;\u521b\u5efa\u5bf9\u8c61\u3001\u7ba1\u7406\u5bf9\u8c61&#034; \u7684\u63a7\u5236\u6743&#xff0c;\u4ece\u5f00\u53d1\u8005\u4ee3\u7801\u4ea4\u7ed9 Spring \u5bb9\u5668<\/li>\n<li>\u4f9d\u8d56\u6ce8\u5165&#xff08;DI&#xff09;&#xff1a;\u7ec4\u4ef6\u9700\u8981\u7684\u4f9d\u8d56\u5bf9\u8c61&#xff0c;\u7531\u5bb9\u5668\u81ea\u52a8\u88c5\u914d\u8fdb\u6765&#xff0c;\u65e0\u9700\u624b\u52a8 new<\/li>\n<\/ul>\n<p>\u6240\u6709 Bean&#xff08;&#064;Service\/&#064;Mapper\/&#064;Controller \u7b49&#xff09;\u5728\u7a0b\u5e8f\u542f\u52a8\u65f6\u88ab\u5bb9\u5668\u521b\u5efa\u3001\u7ba1\u7406&#xff1b;\u9700\u8981\u4f9d\u8d56\u65f6&#xff0c;\u5bb9\u5668\u81ea\u52a8\u6ce8\u5165&#xff0c;\u5b9e\u73b0&#034;\u522b\u627e\u6211&#xff0c;\u6211\u4f1a\u627e\u4f60&#034;\u7684\u8bbe\u8ba1\u54f2\u5b66\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u4ee3\u7801\u91cc\u7684\u4f53\u73b0<\/h3>\n<p>&#064;Service \/\/ 1. \u6ce8\u518c\u4e3aBean&#xff0c;\u4ea4\u7ed9Spring\u7ba1\u7406<br \/>\npublic class EmployeeServiceImpl {<\/p>\n<p>    &#064;Autowired \/\/ 2. \u58f0\u660e\u4f9d\u8d56&#xff0c;\u5bb9\u5668\u81ea\u52a8\u6ce8\u5165<br \/>\n    private EmployeeMapper employeeMapper; \/\/ 3. \u65e0\u9700\u624b\u52a8\u521b\u5efa&#xff0c;\u76f4\u63a5\u4f7f\u7528<\/p>\n<p>    public void login() {<br \/>\n        employeeMapper.getByUsername(&#8230;); \/\/ 4. \u76f4\u63a5\u8c03\u7528<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u6d41\u7a0b\u62c6\u89e3<\/h4>\n<li>\u626b\u63cf\u6ce8\u518c&#xff1a;Spring \u542f\u52a8&#xff0c;\u626b\u63cf &#064;Service\/&#064;Mapper&#xff0c;\u521b\u5efa\u5b9e\u4f8b\u5b58\u5165 IoC \u5bb9\u5668<\/li>\n<li>\u4f9d\u8d56\u6ce8\u5165&#xff1a;\u521b\u5efa EmployeeServiceImpl \u65f6&#xff0c;\u53d1\u73b0 &#064;Autowired&#xff0c;\u4ece\u5bb9\u5668\u4e2d\u53d6\u51fa EmployeeMapper \u6ce8\u5165<\/li>\n<li>\u4f7f\u7528\u5bf9\u8c61&#xff1a;\u5c5e\u6027\u76f4\u63a5\u53ef\u7528&#xff0c;\u5168\u5c40\u5355\u4f8b&#xff0c;\u8282\u7ea6\u8d44\u6e90&#xff0c;\u4fbf\u4e8e\u7ba1\u7406<\/li>\n<hr \/>\n<h3>\u56db\u3001\u4e3a\u4ec0\u4e48\u8981\u7528 IoC\/DI&#xff1f;<\/h3>\n<p>\u6838\u5fc3\u4ef7\u503c&#xff1a;\u89e3\u8026<\/p>\n<ul>\n<li>\u53ea\u4f9d\u8d56\u63a5\u53e3&#xff0c;\u4e0d\u4f9d\u8d56\u5177\u4f53\u5b9e\u73b0\u7c7b<\/li>\n<li>\u66ff\u6362\u5b9e\u73b0\u7c7b\u65f6&#xff0c;\u4e1a\u52a1\u4ee3\u7801\u65e0\u9700\u4fee\u6539<\/li>\n<li>\u7edf\u4e00\u7ba1\u7406\u5bf9\u8c61\u751f\u547d\u5468\u671f&#xff0c;\u652f\u6301\u5355\u4f8b \/ \u591a\u4f8b\u7b49\u7b56\u7565<\/li>\n<\/ul>\n<h4>\u4e00\u53e5\u8bdd\u603b\u7ed3<\/h4>\n<ul>\n<li>\u63a7\u5236\u53cd\u8f6c&#xff08;IoC&#xff09;&#xff1a;\u4ea4\u51fa\u5bf9\u8c61\u521b\u5efa\u4e0e\u7ba1\u7406\u7684\u63a7\u5236\u6743<\/li>\n<li>\u4f9d\u8d56\u6ce8\u5165&#xff08;DI&#xff09;&#xff1a;\u9700\u8981\u7684\u4f9d\u8d56&#xff0c;\u6846\u67b6\u81ea\u52a8\u9001\u8fc7\u6765<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e94\u3001\u5b9e\u6218&#xff1a;\u542f\u7528 \/ \u7981\u7528\u5458\u5de5\u5b8c\u6574\u8c03\u7528\u94fe<\/h3>\n<p>\u4ee5\u542f\u7528 \/ \u7981\u7528\u5458\u5de5\u529f\u80fd\u4e3a\u4f8b&#xff0c;\u6253\u901a\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\u3002<\/p>\n<h4>\u9700\u6c42<\/h4>\n<p>\u7ba1\u7406\u5458\u70b9\u51fb\u7981\u7528\u6309\u94ae&#xff0c;\u5c06\u5458\u5de5\u8d26\u53f7\u72b6\u6001\u6539\u4e3a\u505c\u7528&#xff08;0&#xff09;\u3002<\/p>\n<ul>\n<li>\u524d\u7aef\u8bf7\u6c42&#xff1a;POST \/admin\/employee\/status\/0?id&#061;3<\/li>\n<li>\u542b\u4e49&#xff1a;ID&#061;3 \u7684\u5458\u5de5\u72b6\u6001\u8bbe\u4e3a 0&#xff08;\u7981\u7528&#xff09;<\/li>\n<\/ul>\n<h4>\u7b2c\u4e00\u68d2&#xff1a;Controller \u5c42&#xff08;\u63a5\u5f85\u5458&#xff09;<\/h4>\n<p>\u8d1f\u8d23\u63a5\u6536\u8bf7\u6c42\u3001\u53c2\u6570\u89e3\u6790\u3001\u8c03\u7528 Service\u3001\u8fd4\u56de\u7edf\u4e00\u7ed3\u679c<\/p>\n<p>\/\/ EmployeeController.java<br \/>\n&#064;PostMapping(&#034;\/status\/{status}&#034;)<br \/>\n&#064;ApiOperation(&#034;\u542f\u7528\u7981\u7528\u5458\u5de5\u8d26\u53f7&#034;)<br \/>\npublic Result startOrStop(&#064;PathVariable Integer status, Long id) {<br \/>\n    log.info(&#034;\u542f\u7528\u7981\u7528\u5458\u5de5\u8d26\u53f7&#xff1a;{},{}&#034;, status, id);<br \/>\n    employeeService.startOrStop(status, id);<br \/>\n    return Result.success();<br \/>\n}<\/p>\n<ul>\n<li>\u89e3\u6790 URL \u8def\u5f84\u53c2\u6570status\u4e0e\u8bf7\u6c42\u53c2\u6570id<\/li>\n<li>\u4e0d\u5904\u7406\u4e1a\u52a1&#xff0c;\u76f4\u63a5\u8f6c\u53d1\u7ed9 Service<\/li>\n<li>\u5c01\u88c5 Result \u8fd4\u56de\u524d\u7aef<\/li>\n<\/ul>\n<h4>\u7b2c\u4e8c\u68d2&#xff1a;Service \u5c42&#xff08;\u4e1a\u52a1\u5904\u7406\u5c42&#xff09;<\/h4>\n<p>\u8d1f\u8d23\u4e1a\u52a1\u903b\u8f91\u7f16\u6392\u3001\u6570\u636e\u7ec4\u88c5<\/p>\n<p>\/\/ EmployeeServiceImpl.java<br \/>\n&#064;Override<br \/>\npublic void startOrStop(Integer status, Long id) {<br \/>\n    \/\/ \u7ec4\u88c5\u8981\u66f4\u65b0\u7684\u6570\u636e<br \/>\n    Employee employee &#061; Employee.builder()<br \/>\n            .status(status)<br \/>\n            .id(id)<br \/>\n            .updateTime(LocalDateTime.now())<br \/>\n            .updateUser(BaseContext.getCurrentId())<br \/>\n            .build();<\/p>\n<p>    \/\/ \u4ea4\u7ed9Mapper\u6267\u884c<br \/>\n    employeeMapper.update(employee);<br \/>\n}<\/p>\n<p>\u8e29\u5751\u8bb0\u5f55<\/p>\n<p>\/\/ \u9519\u8bef\u5199\u6cd5&#xff1a;build()\u8fd4\u56de\u65b0\u5bf9\u8c61\u672a\u63a5\u6536&#xff0c;\u4f20\u5165\u7a7a\u5bf9\u8c61<br \/>\nEmployee employee &#061; new Employee();<br \/>\nEmployee.builder().status(status).id(id).build();<br \/>\nemployeeMapper.update(employee); \/\/ SQL\u6761\u4ef6id&#061;null<\/p>\n<p>\u2705 \u6b63\u786e\u5199\u6cd5&#xff1a;\u7528\u53d8\u91cf\u63a5\u6536builder().build()\u8fd4\u56de\u7684\u5bf9\u8c61<\/p>\n<h4>\u7b2c\u4e09\u68d2&#xff1a;Mapper \u5c42&#xff08;\u6570\u636e\u8bbf\u95ee\u5c42&#xff09;<\/h4>\n<p>Mapper \u63a5\u53e3<\/p>\n<p>\/\/ EmployeeMapper.java<br \/>\n&#064;Mapper<br \/>\npublic interface EmployeeMapper {<br \/>\n    void update(Employee employee);<br \/>\n}<\/p>\n<p>XML SQL \u6620\u5c04<\/p>\n<p> EmployeeMapper.xml &#8211;&gt;<br \/>\n&lt;update id&#061;&#034;update&#034; parameterType&#061;&#034;Employee&#034;&gt;<br \/>\n    update employee<br \/>\n    &gt;<br \/>\n        &#061;&#034;name !&#061; null&#034;&gt;name &#061; #{name},&gt;<br \/>\n        &#061;&#034;username !&#061; null&#034;&gt;username &#061; #{username},&gt;<br \/>\n        &#061;&#034;password !&#061; null&#034;&gt;password &#061; #{password},&gt;<br \/>\n        &#061;&#034;phone !&#061; null&#034;&gt;phone &#061; #{phone},&gt;<br \/>\n        &#061;&#034;sex !&#061; null&#034;&gt;sex &#061; #{sex},&gt;<br \/>\n        &#061;&#034;idNumber !&#061; null&#034;&gt;id_number &#061; #{idNumber},  !&#061; null&#034;&gt;update_time &#061; #{updateTime},&gt;<br \/>\n        &#061;&#034;updateUser !&#061; null&#034;&gt;update_user &#061; #{updateUser},  null&#034;&gt;status &#061; #{status},  id &#061; #{id}<br \/>\n&lt;\/update&gt;<\/p>\n<p>MyBatis \u6267\u884c\u6d41\u7a0b<\/p>\n<li>\u6839\u636e\u63a5\u53e3 &#043; \u65b9\u6cd5\u540d\u5339\u914d SQL \u6a21\u677f<\/li>\n<li>\u89e3\u6790&gt;\u52a8\u6001\u62fc\u63a5 SQL<\/li>\n<li>\u66ff\u6362#{}\u5360\u4f4d\u7b26&#xff0c;\u751f\u6210\u53ef\u6267\u884c SQL<\/li>\n<li>\u6267\u884c\u5e76\u8fd4\u56de\u7ed3\u679c<\/li>\n<p>\u6700\u7ec8\u6267\u884c SQL&#xff1a;<\/p>\n<p>update employee set status &#061; 0, update_time &#061; &#039;2026-08-01&#8230;&#039;, update_user &#061; 1 where id &#061; 3<\/p>\n<h4>\u7ed3\u679c\u8fd4\u56de\u94fe\u8def<\/h4>\n<p>\u6570\u636e\u5e93\u66f4\u65b0\u6210\u529f<br \/>\n  \u2192 Mapper \u8fd4\u56de void<br \/>\n    \u2192 Service \u8fd4\u56de void<br \/>\n      \u2192 Controller \u5c01\u88c5 Result.success()<br \/>\n        \u2192 \u524d\u7aef\u6536\u5230 {&#034;code&#034;: 1, &#034;msg&#034;: &#034;\u64cd\u4f5c\u6210\u529f&#034;}<\/p>\n<hr \/>\n<h3>\u516d\u3001\u5b8c\u6574\u8c03\u7528\u94fe\u8def\u56fe<\/h3>\n<p>\u524d\u7aef HTTP \u8bf7\u6c42<br \/>\n    \u2193<br \/>\nController \u5c42&#xff08;\u63a5\u6536\u8bf7\u6c42\u3001\u53c2\u6570\u89e3\u6790&#xff09;<br \/>\n    |  \u6570\u636e\u5f62\u6001&#xff1a;\u96f6\u6563\u53c2\u6570 \u2192 \u4f20\u7ed9Service<br \/>\n    \u2193<br \/>\nService \u5c42&#xff08;\u4e1a\u52a1\u7f16\u6392\u3001\u5bf9\u8c61\u7ec4\u88c5&#xff09;<br \/>\n    |  \u6570\u636e\u5f62\u6001&#xff1a;\u96f6\u6563\u53c2\u6570 \u2192 Employee\u5b9e\u4f53<br \/>\n    \u2193<br \/>\nMapper \u5c42&#xff08;SQL\u751f\u6210\u3001\u6570\u636e\u64cd\u4f5c&#xff09;<br \/>\n    |  \u6570\u636e\u5f62\u6001&#xff1a;\u5b9e\u4f53 \u2192 \u6267\u884cSQL<br \/>\n    \u2193<br \/>\n\u6570\u636e\u5e93\u6267\u884c<br \/>\n    \u2193<br \/>\n\u7ed3\u679c\u5c42\u5c42\u8fd4\u56de \u2192 Controller\u5c01\u88c5 \u2192 \u524d\u7aef\u54cd\u5e94<\/p>\n<hr \/>\n<h3>\u7ed3\u5c3e<\/h3>\n<p>\u4eca\u5929\u7ec8\u4e8e\u641e\u61c2\u4e86IoC\/DI&#xff01;\u770b\u8bfe\u7684\u65f6\u5019\u4e00\u76f4\u4e91\u91cc\u96fe\u91cc\u611f\u89c9\u8ddf\u7740\u6572\u5b8c\u5565\u90fd\u6ca1\u5b66\u5230&#xff1b;\u6253\u901a\u4e86Controller\u2192Service\u2192Mapper\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b&#xff0c;\u7ec8\u4e8e\u662f\u89c9\u5f97\u5b66\u5230\u4e1c\u897f\u4e86\u3002<\/p>\n<p>\u5982\u679c\u4f60\u4e5f\u5728\u5b66 Spring&#xff0c;\u5e0c\u671b\u8fd9\u7bc7\u535a\u5ba2\u80fd\u5e2e\u4f60\u628a IoC\u3001DI \u548c\u4e09\u5c42\u8c03\u7528\u94fe\u5f7b\u5e95\u5403\u900f&#xff5e; \u6b22\u8fce\u8bc4\u8bba\u533a\u4ea4\u6d41&#xff0c;\u4e00\u8d77\u8fdb\u6b65&#xff01;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\u5b66\u4e60\u82cd\u7a79\u5916\u5356\u7b2c 2 \u5929\u3002\u4eca\u5929\u4e0d\u6ee1\u8db3\u4e8e \\&#8221;\u4ee3\u7801\u80fd\u8dd1\u5c31\u884c\\&#8221;&#xff0c;\u6211\u51b3\u5b9a\u5f7b\u5e95\u641e\u6e05\u695a Spring \u6700\u6838\u5fc3\u7684\u4e24\u4e2a\u6982\u5ff5&#xff1a;IoC&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09; \u548c DI&#xff08;\u4f9d\u8d56\u6ce8\u5165&#xff09;\u3002\u7136\u540e\u7528\u4e00\u4e2a\u771f\u5b9e\u7684\u63a5\u53e3&#xff0c;\u628a Controller \u2192 Service \u2192 Mapper \u7684\u5b8c\u6574\u8c03\u7528\u94fe\u8d70\u4e00\u904d\u3002\u4e00\u3001\u4f20\u7edf\u65b9\u5f0f&#xff1a;\u6211\u81ea\u5df1\u62db\u4eba\u5e72\u6d3b\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u6ca1\u6709 Spring \u6846\u67b6&#xff0c;\u6211\u8981\u5f00\u4e00\u5bb6\u9910\u5385\u3002\u6211<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9098,99,1769,101,98],"topic":[],"class_list":["post-89111","post","type-post","status-publish","format-standard","hentry","category-server","tag-it","tag-java","tag-mybatis","tag-spring","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \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\/89111.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00\u5b66\u4e60\u82cd\u7a79\u5916\u5356\u7b2c 2 \u5929\u3002\u4eca\u5929\u4e0d\u6ee1\u8db3\u4e8e &quot;\u4ee3\u7801\u80fd\u8dd1\u5c31\u884c&quot;&#xff0c;\u6211\u51b3\u5b9a\u5f7b\u5e95\u641e\u6e05\u695a Spring \u6700\u6838\u5fc3\u7684\u4e24\u4e2a\u6982\u5ff5&#xff1a;IoC&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09; \u548c DI&#xff08;\u4f9d\u8d56\u6ce8\u5165&#xff09;\u3002\u7136\u540e\u7528\u4e00\u4e2a\u771f\u5b9e\u7684\u63a5\u53e3&#xff0c;\u628a Controller \u2192 Service \u2192 Mapper \u7684\u5b8c\u6574\u8c03\u7528\u94fe\u8d70\u4e00\u904d\u3002\u4e00\u3001\u4f20\u7edf\u65b9\u5f0f&#xff1a;\u6211\u81ea\u5df1\u62db\u4eba\u5e72\u6d3b\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u6ca1\u6709 Spring \u6846\u67b6&#xff0c;\u6211\u8981\u5f00\u4e00\u5bb6\u9910\u5385\u3002\u6211\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/89111.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-02T05:08:25+00:00\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89111.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/89111.html\",\"name\":\"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-02T05:08:25+00:00\",\"dateModified\":\"2026-08-02T05:08:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/89111.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/89111.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89111.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2\"}]},{\"@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":"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \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\/89111.html","og_locale":"zh_CN","og_type":"article","og_title":"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00\u5b66\u4e60\u82cd\u7a79\u5916\u5356\u7b2c 2 \u5929\u3002\u4eca\u5929\u4e0d\u6ee1\u8db3\u4e8e \"\u4ee3\u7801\u80fd\u8dd1\u5c31\u884c\"&#xff0c;\u6211\u51b3\u5b9a\u5f7b\u5e95\u641e\u6e05\u695a Spring \u6700\u6838\u5fc3\u7684\u4e24\u4e2a\u6982\u5ff5&#xff1a;IoC&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09; \u548c DI&#xff08;\u4f9d\u8d56\u6ce8\u5165&#xff09;\u3002\u7136\u540e\u7528\u4e00\u4e2a\u771f\u5b9e\u7684\u63a5\u53e3&#xff0c;\u628a Controller \u2192 Service \u2192 Mapper \u7684\u5b8c\u6574\u8c03\u7528\u94fe\u8d70\u4e00\u904d\u3002\u4e00\u3001\u4f20\u7edf\u65b9\u5f0f&#xff1a;\u6211\u81ea\u5df1\u62db\u4eba\u5e72\u6d3b\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u6ca1\u6709 Spring \u6846\u67b6&#xff0c;\u6211\u8981\u5f00\u4e00\u5bb6\u9910\u5385\u3002\u6211","og_url":"https:\/\/www.wsisp.com\/helps\/89111.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-02T05:08:25+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/89111.html","url":"https:\/\/www.wsisp.com\/helps\/89111.html","name":"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-02T05:08:25+00:00","dateModified":"2026-08-02T05:08:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/89111.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/89111.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/89111.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u901a\u4fd7\u62c6\u89e3Spring IoC\/DI+\u4e09\u5c42\u8c03\u7528\u5168\u6d41\u7a0b\uff5c\u82cd\u7a79\u5916\u5356DAY2"}]},{"@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\/89111","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=89111"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/89111\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=89111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=89111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=89111"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=89111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}