
{"id":2543,"date":"2020-11-28T15:43:53","date_gmt":"2020-11-28T07:43:53","guid":{"rendered":"http:\/\/127.0.0.2\/?p=2543"},"modified":"2020-11-28T15:43:53","modified_gmt":"2020-11-28T07:43:53","slug":"2020javaweb%e6%a1%86%e6%9e%b6%e6%95%99%e7%a8%8b%e4%b9%8bspring%e6%a6%82%e8%bf%b0%e4%bb%a5%e5%8f%8a%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=2543","title":{"rendered":"2020javaweb\u6846\u67b6\u6559\u7a0b\u4e4bspring\u6982\u8ff0\u4ee5\u53ca\u914d\u7f6e"},"content":{"rendered":"<h3>2020javaweb\u6846\u67b6\u6559\u7a0b\u4e4bspring\u6982\u8ff0\u4ee5\u53ca\u914d\u7f6e<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>spring<\/strong><\/span><\/p>\n<p>\u5b98\u7f51\uff1a<a href=\"https:\/\/spring.io\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/spring.io<\/a><\/p>\n<p>\u4f5c\u7528\uff1a\u9879\u2f6c\u7ba1\u7406\u3002 \u7ba1\u7406\u7ec4\u4ef6(\u5bf9\u8c61 DAO\uff0cService\uff0cController)<\/p>\n<p><span style=\"color: #ff0000;\"><strong>spring\u5de5\u5382\u642d\u5efa<\/strong><\/span><\/p>\n<p><span style=\"color: #ff0000;\">1.\u5bfc\u5165\u4f9d\u8d56<\/span><\/p>\n<pre>&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-context-support&lt;\/artifactId&gt;\r\n  &lt;version&gt;4.3.6.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/28\/19.png\" alt=\"\" width=\"680\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>2.\u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/p>\n<p>\u4f5c\u7528\uff1a\u63cf\u8ff0\u54ea\u4e9b\u7ec4\u4ef6\u9700\u8981spring\u2f63\u4ea7\uff0c\u7ba1\u7406<\/p>\n<p>\u6587\u4ef6\u4f4d\u7f6e\uff1asrc&#8211;&gt;&#8211;&gt;main&#8211;&gt;resources\u76ee\u5f55<\/p>\n<p>\u6587\u4ef6\u540d\u968f\u610f\uff0c\u5982\uff1aapplicationContext.xml<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\r\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n       xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n       xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans\r\nhttp:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\"&gt;\r\n\r\n    &lt;!-- \u4f5c\u2f64\uff1a\u58f0\u660e\u9700\u8981spring \u2f63\u4ea7\u7684\u7ec4\u4ef6 --&gt;\r\n    &lt;!-- UserDAOImpl\u7ec4\u4ef6 id=\"\u7ec4\u4ef6\u6807\u8bc6\" class=\"\u7ec4\u4ef6\u7c7b\u578b\" --&gt;\r\n    &lt;bean id=\"userDAO\" class=\"dao.impl.UsersDaoImpl\"\/&gt;\r\n\r\n&lt;\/beans&gt;<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/28\/20.png\" alt=\"\" width=\"680\" \/><\/p>\n<p><strong><span style=\"color: #ff0000;\">3.\u542f\u52a8\u5de5\u5382<\/span><\/strong><\/p>\n<p>\u5de5\u5382\u63a5\u53e3\uff1aApplicationContext<br \/>\n\u5b9e\u73b0\u7c7b\uff1aClassPathXmlApplicationContext<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/28\/21.png\" alt=\"\" width=\"680\" \/><\/p>\n<p>service\u65e0\u5e8f\u8c03\u7528dao\u7684\u5b9e\u73b0\u7c7b\uff0c\u76f4\u63a5\u521b\u5efadao\u5e76\u6dfb\u52a0set\/get\u65b9\u6cd5\uff0c\u7136\u540e\u5728applicationContext.xml\u914d\u7f6e<\/p>\n<pre>&lt;!-- spring\u751f\u6210\u8be5\u5bf9\u8c61\uff0c\u5bf9\u8c61\u4e2d\u6709\u4e00\u4e2a\u5c5e\u6027\u9700\u8981\u8d4b\u503c--&gt;\r\n&lt;bean id=\"userService\" class=\"service.impl.UsersServiceImpl\"&gt;\r\n&lt;!--  \u7ed9\u5c5e\u6027 UsersDao \u7684\u53d8\u91cf \u8d4b\u503c\uff0c\u503c\uff1aid=\"userDAO\"   --&gt;\r\n&lt;property name=\"ud\" ref=\"userDAO\"\/&gt;\r\n&lt;\/bean&gt;<\/pre>\n<p>\u7136\u540e\u518d\u53bb\u5de5\u5382\u53bb\u751f\u6210\u4e00\u4e2a<\/p>\n<pre>UsersService us = context.getBean(\"userService\", UsersService.class);\r\nus.insert(new Users());<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>2020javaweb\u6846\u67b6\u6559\u7a0b\u4e4bspring\u6982\u8ff0\u4ee5\u53ca\u914d\u7f6e spring \u5b98\u7f51\uff1ahttps:\/\/spring.i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2543","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2543"}],"version-history":[{"count":1,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2543\/revisions"}],"predecessor-version":[{"id":2544,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2543\/revisions\/2544"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}