{"id":1936,"date":"2023-08-05T09:38:21","date_gmt":"2023-08-05T01:38:21","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=1936"},"modified":"2023-08-05T09:38:21","modified_gmt":"2023-08-05T01:38:21","slug":"app%e5%8f%af%e4%bb%a5%e7%94%a8ssm%e6%a1%86%e6%9e%b6%e5%bc%80%e5%8f%91%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/1936\/","title":{"rendered":"app\u53ef\u4ee5\u7528ssm\u6846\u67b6\u5f00\u53d1\u4e48\uff1f"},"content":{"rendered":"

\u5f53\u7136\u53ef\u4ee5\uff01SSM\u6846\u67b6\u662f\u6307Spring + SpringMVC + MyBatis\u7684\u7ec4\u5408\uff0c\u5b83\u4eec\u662f\u76ee\u524d\u975e\u5e38\u6d41\u884c\u7684Java Web\u5f00\u53d1\u6846\u67b6\u3002SSM\u6846\u67b6\u96c6\u6210\u4e86Spring\u7684\u4f9d\u8d56\u6ce8\u5165\u548c\u63a7\u5236\u53cd\u8f6c\u3001SpringMVC\u7684\u8bf7\u6c42\u5904\u7406\u548c\u89c6\u56fe\u89e3\u6790\u3001MyBatis\u7684ORM\uff08\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff09\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u9ad8\u6548\u3001\u53ef\u9760\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecdSSM\u6846\u67b6\u7684\u539f\u7406\u548c\u5404\u4e2a\u7ec4\u4ef6\u7684\u4f5c\u7528\uff1a<\/p>\n

1. Spring\u6846\u67b6\uff1a<\/p>\n

Spring\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Java\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u4f9d\u8d56\u6ce8\u5165\u548c\u63a7\u5236\u53cd\u8f6c\u7684\u529f\u80fd\uff0c\u4f7f\u5f97\u7ec4\u4ef6\u4e4b\u95f4\u7684\u8026\u5408\u5ea6\u964d\u4f4e\u3002Spring\u7684\u6838\u5fc3\u5bb9\u5668\u662fBeanFactory\u548cApplicationContext\uff0c\u5b83\u4eec\u8d1f\u8d23\u7ba1\u7406\u548c\u521b\u5efa\u5bf9\u8c61\u3002\u5728SSM\u6846\u67b6\u4e2d\uff0cSpring\u8d1f\u8d23\u7ba1\u7406\u548c\u521b\u5efaService\u5c42\u548cDAO\u5c42\u7684\u5bf9\u8c61\u3002<\/p>\n

2. SpringMVC\u6846\u67b6\uff1a<\/p>\n

SpringMVC\u662f\u57fa\u4e8eMVC\uff08\u6a21\u578b-\u89c6\u56fe-\u63a7\u5236\u5668\uff09\u8bbe\u8ba1\u6a21\u5f0f\u7684Web\u6846\u67b6\uff0cAPP<\/a>\u5b83\u63d0\u4f9b\u4e86\u8bf7\u6c42\u5904\u7406\u3001\u89c6\u56fe\u89e3\u6790\u548c\u6570\u636e\u7ed1\u5b9a\u7b49\u529f\u80fd\u3002SpringMVC\u7684\u6838\u5fc3\u662fDispatcherServlet\uff0c\u5b83\u8d1f\u8d23\u63a5\u6536\u7528\u6237\u8bf7\u6c42\u5e76\u5c06\u8bf7\u6c42\u5206\u53d1\u7ed9\u5bf9\u5e94\u7684Controller\u5904\u7406\u3002\u5728SSM\u6846\u67b6\u4e2d\uff0cSpringMVC\u8d1f\u8d23\u5904\u7406\u7528\u6237\u8bf7\u6c42\u548c\u8fd4\u56de\u89c6\u56fe\u3002<\/p>\n

3. MyBatis\u6846\u67b6\uff1a<\/p>\n

MyBatis\u662f\u4e00\u4e2a\u6301\u4e45\u5c42\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff08ORM\uff09\u529f\u80fd\uff0c\u5c06\u6570\u636e\u5e93\u8868\u548cJava\u5bf9\u8c61\u4e4b\u95f4\u8fdb\u884c\u6620\u5c04\u3002MyBatis\u4f7f\u7528XML\u6587\u4ef6\u6216\u6ce8\u89e3\u914d\u7f6eSQL\u8bed\u53e5\u548c\u53c2\u6570\u6620\u5c04\u5173\u7cfb\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5728SSM\u6846\u67b6\u4e2d\uff0cMyBatis\u8d1f\u8d23\u5c06\u6570\u636e\u5e93\u67e5\u8be2\u7ed3\u679c\u6620\u5c04\u4e3aJava\u5bf9\u8c61\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e8b\u52a1\u7ba1\u7406\u529f\u80fd\u3002<\/p>\n

SSM\u6846\u67b6\u7684\u5f00\u53d1\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n

1. \u914d\u7f6eSpring\uff1a<\/p>\n

\u9996\u5148\uff0c\u9700\u8981\u5728\u9879\u76ee\u4e2d\u914d\u7f6eSpring\u7684\u76f8\u5173\u6587\u4ef6\uff0c\u5305\u62ecapplicationContext.xml\u548cspringmvc.xml\u3002applicationContext.xml\u8d1f\u8d23\u914d\u7f6eSpring\u7684\u6838\u5fc3\u5bb9\u5668\u548c\u626b\u63cf\u5305\uff0cspringmvc.xml\u8d1f\u8d23\u914d\u7f6eSpringMVC\u7684\u76f8\u5173\u5185\u5bb9\u3002<\/p>\n

2. \u914d\u7f6eMyBatis\uff1a<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u9700\u8981\u914d\u7f6eMyBatis\u7684\u76f8\u5173\u6587\u4ef6\uff0c\u5305\u62ecmybatis-config.xml\u548cMapper.xml\u3002mybatis-config.xml\u8d1f\u8d23\u914d\u7f6eMyBatis\u7684\u6838\u5fc3\u8bbe\u7f6e\uff0cMapper.xml\u8d1f\u8d23\u914d\u7f6eSQL\u8bed\u53e5\u548c\u53c2\u6570\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n

3. \u7f16\u5199\u5b9e\u4f53\u7c7b\u548cMapper\u63a5\u53e3\uff1a<\/p>\n

\u7136\u540e\uff0c\u9700\u8981\u7f16\u5199\u5b9e\u4f53\u7c7b\u548cMapper\u63a5\u53e3\u3002\u5b9e\u4f53\u7c7b\u7528\u4e8e\u6620\u5c04APP\u5f00\u53d1<\/a>\u6570\u636e\u5e93\u8868\uff0cMapper\u63a5\u53e3\u7528\u4e8e\u5b9a\u4e49\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u65b9\u6cd5\u3002<\/p>\n

4. \u5b9e\u73b0Mapper\u63a5\u53e3\uff1a<\/p>\n

\u63a5\u7740\uff0c\u9700\u8981\u7f16\u5199Mapper\u63a5\u53e3\u7684\u5b9e\u73b0\u7c7b\uff0c\u4f7f\u7528MyBatis\u63d0\u4f9b\u7684API\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u5728\u5b9e\u73b0\u7c7b\u4e2d\uff0c\u53ef\u4ee5\u8c03\u7528MyBatis\u7684SQL\u8bed\u53e5\u548c\u53c2\u6570\u6620\u5c04\u5173\u7cfb\uff0c\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002<\/p>\n

5. \u7f16\u5199Service\u5c42\uff1a<\/p>\n

\u7136\u540e\uff0c\u9700\u8981\u7f16\u5199Service\u5c42\u7684\u7c7b\uff0c\u7528\u4e8e\u5c01\u88c5\u4e1a\u52a1\u903b\u8f91\u3002\u5728Service\u5c42\u4e2d\uff0c\u53ef\u4ee5\u8c03\u7528Mapper\u63a5\u53e3\u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5\uff0c\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002<\/p>\n

6. \u7f16\u5199Controller\u5c42\uff1a<\/p>\n

\u6700\u540e\uff0c\u9700\u8981\u7f16\u5199Controller\u5c42\u7684\u7c7b\uff0c<\/p>\n

<\/figure>\n<\/p>\n

\u7528\u4e8e\u5904\u7406\u7528\u6237\u8bf7\u6c42\u548c\u8fd4\u56de\u89c6\u56fe\u3002\u5728Controller\u5c42\u4e2d\uff0c\u53ef\u4ee5\u8c03\u7528Service\u5c42\u4e2d\u7684\u65b9\u6cd5\uff0c\u8fdb\u884c\u4e1a\u52a1\u5904\u7406\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u89c6\u56fe\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528SSM\u6846\u67b6\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002SSM\u6846\u67b6\u7684\u4f18\u70b9\u662f\u7ec4\u4ef6\u5316\u3001\u4f4e\u8026\u5408\u3001\u6613\u4e8e\u7ef4\u62a4\u548c\u6269\u5c55\uff0c\u9002\u5408\u4e2d\u5c0f\u578b\u9879\u76ee\u7684\u5f00\u53d1\u3002\u540c\u65f6\uff0cSSM\u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u63d2\u4ef6\u548c\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5e0c\u671b\u672c\u7bc7\u6587\u7ae0\u80fd\u5bf9\u4f60\u7406\u89e3SSM\u6846\u67b6\u7684\u539f\u7406\u548c\u4f7f\u7528\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5f53\u7136\u53ef\u4ee5\uff01SSM\u6846\u67b6\u662f\u6307Spring + SpringMVC + MyBatis\u7684\u7ec4\u5408\uff0c\u5b83\u4eec\u662f\u76ee\u524d\u975e\u5e38\u6d41\u884c\u7684Java Web\u5f00\u53d1\u6846\u67b6\u3002SSM\u6846\u67b6\u96c6\u6210\u4e86Spring\u7684\u4f9d\u8d56\u6ce8\u5165\u548c\u63a7\u5236\u53cd\u8f6c\u3001SpringM<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[4136,4137,369,384,757],"topic":[],"class_list":["post-1936","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-app","tag-exe","tag-369","tag-384","tag-757"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/1936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=1936"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/1936\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=1936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=1936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=1936"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=1936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}