{"id":532,"date":"2023-03-23T21:19:42","date_gmt":"2023-03-23T13:19:42","guid":{"rendered":""},"modified":"2023-03-23T21:19:42","modified_gmt":"2023-03-23T13:19:42","slug":"spring \u521b\u5efa\u5e94\u7528","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/532.html","title":{"rendered":"spring \u521b\u5efa\u5e94\u7528"},"content":{"rendered":"
\n
\u521b\u5efaJava\u9879\u76ee<\/span> org.springframework.core-3.0.1.RELEASE-A <\/strong> <\/span> <\/code>\n <\/div>\n <\/code>\n <\/div>\n <\/code>\n <\/div>\n
\n \u6dfb\u52a0spring jar\u6587\u4ef6<\/span>
\n \u521b\u5efa\u7c7b<\/span>
\n \u521b\u5efaxml\u6587\u4ef6\u4ee5\u63d0\u4f9b\u503c<\/span>
\n \u521b\u5efa\u6d4b\u8bd5\u7c7b<\/span> <\/p>\n
\n\u5728Eclipse IDE\u4e2d\u521b\u5efaspring\u5e94\u7528\u7a0b\u5e8f\u7684\u6b65\u9aa4<\/h2>\n
1\u3001\u521b\u5efaJava\u9879\u76ee<\/h3>\n
\n \u6587\u4ef6<\/strong>\u83dc\u5355-
\n \u65b0\u5efa<\/strong>-
\n \u9879\u76ee<\/strong>-
\n Java\u9879\u76ee<\/strong>\u3002\u8f93\u5165\u9879\u76ee\u540d\u79f0\uff0c\u4f8b\u5982firstspring-
\n \u5b8c\u6210<\/strong>\u3002\u73b0\u5728\uff0c\u521b\u5efa\u4e86Java\u9879\u76ee\u3002\n <\/div>\n 2\u3001\u6dfb\u52a0spring jar\u6587\u4ef6<\/h3>\n
\n com.springsource.org.apache.commons.logging-1.1.1 <\/strong> <\/span>
\n org.springframework.beans-3.0.1.RELEASE-A <\/strong> <\/span> <\/p>\n
\n \u53f3\u952e\u5355\u51fb\u60a8\u7684\u9879\u76ee<\/strong>-
\n \u6784\u5efa\u8def\u5f84<\/strong>-
\n \u6dfb\u52a0\u5916\u90e8\u6863\u6848\u6587\u4ef6<\/strong>-
\n \u9009\u62e9\u6240\u6709\u5fc5\u9700\u7684\u6587\u4ef6jar\u6587\u4ef6<\/strong>-
\n \u5b8c\u6210\u3002<\/strong>\u3002\n <\/div>\n 3\u3001\u521b\u5efaJava\u7c7b<\/h3>\n
\n \u53f3\u952e\u5355\u51fbsrc <\/strong>-
\n \u65b0\u5efa<\/strong>-
\n \u7c7b<\/strong>-
\n \u5199\u7c7b\u540d\u79f0\uff0c\u4f8b\u5982\u5b66\u751f<\/strong>-
\n \u5b8c\u6210<\/strong>\u3002\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801:\n <\/div>\n\npackage <\/span>com.lidihuo;\npublic <\/span>class <\/span>Student {\nprivate <\/span>String name;\npublic <\/span>String getName() {\n return <\/span>name;\n}\npublic void <\/span>setName(String name) {\n this<\/span>.name = name;\n}\npublic void <\/span>displayInfo(){\n System.out.println<\/span>(\"Hello: \"<\/span>+name);\n}\n}\n<\/pre>\n
4\u3001\u521b\u5efaxml\u6587\u4ef6<\/h3>\n
\n<?xml version=\"1.0\"<\/span> encoding=\"UTF-8\"<\/span>?>\n<beans\n xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"<\/span>\n xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"<\/span>\n xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\"<\/span>\n xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans\n http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\">\n<bean id=\"studentbean\"<\/span> class=\"com.lidihuo.Student\"<\/span>>\n<property name=\"name\"<\/span> value=\"Vimal Jaiswal\"<\/span>><\/property>\n<\/bean>\n<\/beans>\n<\/pre>\n
\n property <\/strong>\u5b50\u5143\u7d20\u6307\u5b9a\u540d\u4e3aname\u7684Student\u7c7b\u7684\u5c5e\u6027\u3002\u5c5e\u6027\u5143\u7d20\u4e2d\u6307\u5b9a\u7684\u503c\u5c06\u7531IOC\u5bb9\u5668\u5728Student\u7c7b\u5bf9\u8c61\u4e2d\u8bbe\u7f6e\u3002\n <\/div>\n 5\u3001\u521b\u5efa\u6d4b\u8bd5\u7c7b<\/h3>\n
\npackage <\/span>com.lidihuo;\nimport org.springframework.beans.factory.BeanFactory;\nimport org.springframework.beans.factory.xml.XmlBeanFactory;\nimport org.springframework.core.io.ClassPathResource;\nimport org.springframework.core.io.Resource;\npublic <\/span>class <\/span>Test {\npublic <\/span>static void <\/span>main(String[] args) {\n Resource resource=new ClassPathResource(\"applicationContext.xml\"<\/span>);\n BeanFactory factory=new XmlBeanFactory(resource);\n \n Student student=(Student)factory.getBean<\/span>(\"studentbean\"<\/span>);\n student.displayInfo<\/span>();\n}\n}\n<\/pre>\n
\n <\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"spring \u521b\u5efa\u5e94\u7528zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-532","post","type-post","status-publish","format-standard","hentry","category-bc_spring_jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/532"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}