ToB企服应用市场:ToB评测及商务社交产业平台

标题: Spring6 初始 [打印本页]

作者: 立聪堂德州十三局店    时间: 2023-7-19 11:23
标题: Spring6 初始
Spring6 初始

@
目录

每博一文案:
  1. 人生的态度是:抱有最大的希望。
  2. 尽最大的努力,做最坏的打算。
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <beans xmlns="http://www.springframework.org/schema/beans"
  7.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  9.     <bean id="vipBean" />
  10. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11. <?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15.     <bean id="vipBean" />
  16. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17. <?xml version="1.0" encoding="UTF-8"?>
  18. <beans xmlns="http://www.springframework.org/schema/beans"
  19.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  21.     <bean id="vipBean" />
  22. </beans><bean id="userBean2" ></bean>
  23. <?xml version="1.0" encoding="UTF-8"?>
  24. <beans xmlns="http://www.springframework.org/schema/beans"
  25.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  26.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  27.     <bean id="vipBean" />
  28. </beans>
  29. </beans><?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41.     <bean id="vipBean" />
  42. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <beans xmlns="http://www.springframework.org/schema/beans"
  45.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  46.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  47.     <bean id="vipBean" />
  48. </beans><bean id="userBean2" ></bean>
  49. <?xml version="1.0" encoding="UTF-8"?>
  50. <beans xmlns="http://www.springframework.org/schema/beans"
  51.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  52.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  53.     <bean id="vipBean" />
  54. </beans>
  55. </beans><?xml version="1.0" encoding="UTF-8"?>
  56. <beans xmlns="http://www.springframework.org/schema/beans"
  57. <?xml version="1.0" encoding="UTF-8"?>
  58. <beans xmlns="http://www.springframework.org/schema/beans"
  59.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61.     <bean id="vipBean" />
  62. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  63. <?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  66.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  67.     <bean id="vipBean" />
  68. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  69. <?xml version="1.0" encoding="UTF-8"?>
  70. <beans xmlns="http://www.springframework.org/schema/beans"
  71.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  72.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  73.     <bean id="vipBean" />
  74. </beans><bean id="userBean2" ></bean>
  75. <?xml version="1.0" encoding="UTF-8"?>
  76. <beans xmlns="http://www.springframework.org/schema/beans"
  77.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  78.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  79.     <bean id="vipBean" />
  80. </beans>
  81. </beans><?xml version="1.0" encoding="UTF-8"?>
  82. <beans xmlns="http://www.springframework.org/schema/beans"
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  87.     <bean id="vipBean" />
  88. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  89. <?xml version="1.0" encoding="UTF-8"?>
  90. <beans xmlns="http://www.springframework.org/schema/beans"
  91.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  92.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  93.     <bean id="vipBean" />
  94. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95. <?xml version="1.0" encoding="UTF-8"?>
  96. <beans xmlns="http://www.springframework.org/schema/beans"
  97.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  98.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  99.     <bean id="vipBean" />
  100. </beans><bean id="userBean2" ></bean>
  101. <?xml version="1.0" encoding="UTF-8"?>
  102. <beans xmlns="http://www.springframework.org/schema/beans"
  103.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  104.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  105.     <bean id="vipBean" />
  106. </beans>
  107. </beans>  —————— 柏拉图《理想国》
复制代码
1. 初始 Spring6

阅读以下代码:
  1. package com.powernode.oa.controller;
  2. import com.powernode.oa.service.UserService;
  3. import com.powernode.oa.service.impl.UserServiceImpl;
  4. public class UserController {
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <beans xmlns="http://www.springframework.org/schema/beans"
  7.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  9.     <bean id="vipBean" />
  10. </beans>private UserService userService = new UserServiceImpl();
  11. <?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15.     <bean id="vipBean" />
  16. </beans>public void login(){
  17. <?xml version="1.0" encoding="UTF-8"?>
  18. <beans xmlns="http://www.springframework.org/schema/beans"
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans><bean id="userBean2" ></bean>
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41.     <bean id="vipBean" />
  42. </beans>
  43. </beans>String username = "admin";
  44. <?xml version="1.0" encoding="UTF-8"?>
  45. <beans xmlns="http://www.springframework.org/schema/beans"
  46. <?xml version="1.0" encoding="UTF-8"?>
  47. <beans xmlns="http://www.springframework.org/schema/beans"
  48.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  49.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  50.     <bean id="vipBean" />
  51. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  52. <?xml version="1.0" encoding="UTF-8"?>
  53. <beans xmlns="http://www.springframework.org/schema/beans"
  54.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  55.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  56.     <bean id="vipBean" />
  57. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  58. <?xml version="1.0" encoding="UTF-8"?>
  59. <beans xmlns="http://www.springframework.org/schema/beans"
  60.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  61.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  62.     <bean id="vipBean" />
  63. </beans><bean id="userBean2" ></bean>
  64. <?xml version="1.0" encoding="UTF-8"?>
  65. <beans xmlns="http://www.springframework.org/schema/beans"
  66.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  67.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  68.     <bean id="vipBean" />
  69. </beans>
  70. </beans>String password = "123456";
  71. <?xml version="1.0" encoding="UTF-8"?>
  72. <beans xmlns="http://www.springframework.org/schema/beans"
  73. <?xml version="1.0" encoding="UTF-8"?>
  74. <beans xmlns="http://www.springframework.org/schema/beans"
  75.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  76.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77.     <bean id="vipBean" />
  78. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  79. <?xml version="1.0" encoding="UTF-8"?>
  80. <beans xmlns="http://www.springframework.org/schema/beans"
  81.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  82.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  83.     <bean id="vipBean" />
  84. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  85. <?xml version="1.0" encoding="UTF-8"?>
  86. <beans xmlns="http://www.springframework.org/schema/beans"
  87.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  88.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  89.     <bean id="vipBean" />
  90. </beans><bean id="userBean2" ></bean>
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>
  97. </beans>boolean success = userService.login(username, password);
  98. <?xml version="1.0" encoding="UTF-8"?>
  99. <beans xmlns="http://www.springframework.org/schema/beans"
  100. <?xml version="1.0" encoding="UTF-8"?>
  101. <beans xmlns="http://www.springframework.org/schema/beans"
  102.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  103.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  104.     <bean id="vipBean" />
  105. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106. <?xml version="1.0" encoding="UTF-8"?>
  107. <beans xmlns="http://www.springframework.org/schema/beans"
  108.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  109.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  110.     <bean id="vipBean" />
  111. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  112. <?xml version="1.0" encoding="UTF-8"?>
  113. <beans xmlns="http://www.springframework.org/schema/beans"
  114.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  115.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  116.     <bean id="vipBean" />
  117. </beans><bean id="userBean2" ></bean>
  118. <?xml version="1.0" encoding="UTF-8"?>
  119. <beans xmlns="http://www.springframework.org/schema/beans"
  120.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  121.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  122.     <bean id="vipBean" />
  123. </beans>
  124. </beans>if (success) {
  125. <?xml version="1.0" encoding="UTF-8"?>
  126. <beans xmlns="http://www.springframework.org/schema/beans"
  127. <?xml version="1.0" encoding="UTF-8"?>
  128. <beans xmlns="http://www.springframework.org/schema/beans"
  129.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  130.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  131.     <bean id="vipBean" />
  132. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  133. <?xml version="1.0" encoding="UTF-8"?>
  134. <beans xmlns="http://www.springframework.org/schema/beans"
  135.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  136.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  137.     <bean id="vipBean" />
  138. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139. <?xml version="1.0" encoding="UTF-8"?>
  140. <beans xmlns="http://www.springframework.org/schema/beans"
  141.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  142.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  143.     <bean id="vipBean" />
  144. </beans><bean id="userBean2" ></bean>
  145. <?xml version="1.0" encoding="UTF-8"?>
  146. <beans xmlns="http://www.springframework.org/schema/beans"
  147.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  148.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  149.     <bean id="vipBean" />
  150. </beans>
  151. </beans><?xml version="1.0" encoding="UTF-8"?>
  152. <beans xmlns="http://www.springframework.org/schema/beans"
  153.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  154.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  155.     <bean id="vipBean" />
  156. </beans>// 登录成功
  157. <?xml version="1.0" encoding="UTF-8"?>
  158. <beans xmlns="http://www.springframework.org/schema/beans"
  159. <?xml version="1.0" encoding="UTF-8"?>
  160. <beans xmlns="http://www.springframework.org/schema/beans"
  161.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  162.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  163.     <bean id="vipBean" />
  164. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  165. <?xml version="1.0" encoding="UTF-8"?>
  166. <beans xmlns="http://www.springframework.org/schema/beans"
  167.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  168.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  169.     <bean id="vipBean" />
  170. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  171. <?xml version="1.0" encoding="UTF-8"?>
  172. <beans xmlns="http://www.springframework.org/schema/beans"
  173.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  174.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  175.     <bean id="vipBean" />
  176. </beans><bean id="userBean2" ></bean>
  177. <?xml version="1.0" encoding="UTF-8"?>
  178. <beans xmlns="http://www.springframework.org/schema/beans"
  179.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  180.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181.     <bean id="vipBean" />
  182. </beans>
  183. </beans>} else {
  184. <?xml version="1.0" encoding="UTF-8"?>
  185. <beans xmlns="http://www.springframework.org/schema/beans"
  186. <?xml version="1.0" encoding="UTF-8"?>
  187. <beans xmlns="http://www.springframework.org/schema/beans"
  188.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  189.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  190.     <bean id="vipBean" />
  191. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  192. <?xml version="1.0" encoding="UTF-8"?>
  193. <beans xmlns="http://www.springframework.org/schema/beans"
  194.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  195.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  196.     <bean id="vipBean" />
  197. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  198. <?xml version="1.0" encoding="UTF-8"?>
  199. <beans xmlns="http://www.springframework.org/schema/beans"
  200.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  201.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  202.     <bean id="vipBean" />
  203. </beans><bean id="userBean2" ></bean>
  204. <?xml version="1.0" encoding="UTF-8"?>
  205. <beans xmlns="http://www.springframework.org/schema/beans"
  206.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  207.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  208.     <bean id="vipBean" />
  209. </beans>
  210. </beans><?xml version="1.0" encoding="UTF-8"?>
  211. <beans xmlns="http://www.springframework.org/schema/beans"
  212.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  213.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  214.     <bean id="vipBean" />
  215. </beans>// 登录失败
  216. <?xml version="1.0" encoding="UTF-8"?>
  217. <beans xmlns="http://www.springframework.org/schema/beans"
  218. <?xml version="1.0" encoding="UTF-8"?>
  219. <beans xmlns="http://www.springframework.org/schema/beans"
  220.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  221.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  222.     <bean id="vipBean" />
  223. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  224. <?xml version="1.0" encoding="UTF-8"?>
  225. <beans xmlns="http://www.springframework.org/schema/beans"
  226.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  227.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  228.     <bean id="vipBean" />
  229. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  230. <?xml version="1.0" encoding="UTF-8"?>
  231. <beans xmlns="http://www.springframework.org/schema/beans"
  232.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  233.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  234.     <bean id="vipBean" />
  235. </beans><bean id="userBean2" ></bean>
  236. <?xml version="1.0" encoding="UTF-8"?>
  237. <beans xmlns="http://www.springframework.org/schema/beans"
  238.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  239.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  240.     <bean id="vipBean" />
  241. </beans>
  242. </beans>}
  243. <?xml version="1.0" encoding="UTF-8"?>
  244. <beans xmlns="http://www.springframework.org/schema/beans"
  245.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  246.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  247.     <bean id="vipBean" />
  248. </beans>}
  249. }
  250. package com.powernode.oa.service.impl;
  251. import com.powernode.oa.bean.User;
  252. import com.powernode.oa.dao.UserDao;
  253. import com.powernode.oa.dao.impl.UserDaoImplForMySQL;
  254. import com.powernode.oa.service.UserService;
  255. public class UserServiceImpl implements UserService {
  256. <?xml version="1.0" encoding="UTF-8"?>
  257. <beans xmlns="http://www.springframework.org/schema/beans"
  258.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  259.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  260.     <bean id="vipBean" />
  261. </beans>private UserDao userDao = new UserDaoImplForMySQL();
  262. <?xml version="1.0" encoding="UTF-8"?>
  263. <beans xmlns="http://www.springframework.org/schema/beans"
  264.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  265.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  266.     <bean id="vipBean" />
  267. </beans>public boolean login(String username, String password) {
  268. <?xml version="1.0" encoding="UTF-8"?>
  269. <beans xmlns="http://www.springframework.org/schema/beans"
  270. <?xml version="1.0" encoding="UTF-8"?>
  271. <beans xmlns="http://www.springframework.org/schema/beans"
  272.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  273.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  274.     <bean id="vipBean" />
  275. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  276. <?xml version="1.0" encoding="UTF-8"?>
  277. <beans xmlns="http://www.springframework.org/schema/beans"
  278.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  279.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  280.     <bean id="vipBean" />
  281. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  282. <?xml version="1.0" encoding="UTF-8"?>
  283. <beans xmlns="http://www.springframework.org/schema/beans"
  284.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  285.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  286.     <bean id="vipBean" />
  287. </beans><bean id="userBean2" ></bean>
  288. <?xml version="1.0" encoding="UTF-8"?>
  289. <beans xmlns="http://www.springframework.org/schema/beans"
  290.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  291.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  292.     <bean id="vipBean" />
  293. </beans>
  294. </beans>User user = userDao.selectByUsernameAndPassword(username, password);
  295. <?xml version="1.0" encoding="UTF-8"?>
  296. <beans xmlns="http://www.springframework.org/schema/beans"
  297. <?xml version="1.0" encoding="UTF-8"?>
  298. <beans xmlns="http://www.springframework.org/schema/beans"
  299.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  300.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  301.     <bean id="vipBean" />
  302. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  303. <?xml version="1.0" encoding="UTF-8"?>
  304. <beans xmlns="http://www.springframework.org/schema/beans"
  305.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  306.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  307.     <bean id="vipBean" />
  308. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  309. <?xml version="1.0" encoding="UTF-8"?>
  310. <beans xmlns="http://www.springframework.org/schema/beans"
  311.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  312.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  313.     <bean id="vipBean" />
  314. </beans><bean id="userBean2" ></bean>
  315. <?xml version="1.0" encoding="UTF-8"?>
  316. <beans xmlns="http://www.springframework.org/schema/beans"
  317.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  318.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  319.     <bean id="vipBean" />
  320. </beans>
  321. </beans>if (user != null) {
  322. <?xml version="1.0" encoding="UTF-8"?>
  323. <beans xmlns="http://www.springframework.org/schema/beans"
  324. <?xml version="1.0" encoding="UTF-8"?>
  325. <beans xmlns="http://www.springframework.org/schema/beans"
  326.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  327.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  328.     <bean id="vipBean" />
  329. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  330. <?xml version="1.0" encoding="UTF-8"?>
  331. <beans xmlns="http://www.springframework.org/schema/beans"
  332.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  333.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  334.     <bean id="vipBean" />
  335. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  336. <?xml version="1.0" encoding="UTF-8"?>
  337. <beans xmlns="http://www.springframework.org/schema/beans"
  338.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  339.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  340.     <bean id="vipBean" />
  341. </beans><bean id="userBean2" ></bean>
  342. <?xml version="1.0" encoding="UTF-8"?>
  343. <beans xmlns="http://www.springframework.org/schema/beans"
  344.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  345.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  346.     <bean id="vipBean" />
  347. </beans>
  348. </beans><?xml version="1.0" encoding="UTF-8"?>
  349. <beans xmlns="http://www.springframework.org/schema/beans"
  350.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  351.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  352.     <bean id="vipBean" />
  353. </beans>return true;
  354. <?xml version="1.0" encoding="UTF-8"?>
  355. <beans xmlns="http://www.springframework.org/schema/beans"
  356. <?xml version="1.0" encoding="UTF-8"?>
  357. <beans xmlns="http://www.springframework.org/schema/beans"
  358.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  359.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  360.     <bean id="vipBean" />
  361. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  362. <?xml version="1.0" encoding="UTF-8"?>
  363. <beans xmlns="http://www.springframework.org/schema/beans"
  364.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  365.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  366.     <bean id="vipBean" />
  367. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  368. <?xml version="1.0" encoding="UTF-8"?>
  369. <beans xmlns="http://www.springframework.org/schema/beans"
  370.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  371.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  372.     <bean id="vipBean" />
  373. </beans><bean id="userBean2" ></bean>
  374. <?xml version="1.0" encoding="UTF-8"?>
  375. <beans xmlns="http://www.springframework.org/schema/beans"
  376.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  377.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  378.     <bean id="vipBean" />
  379. </beans>
  380. </beans>}
  381. <?xml version="1.0" encoding="UTF-8"?>
  382. <beans xmlns="http://www.springframework.org/schema/beans"
  383. <?xml version="1.0" encoding="UTF-8"?>
  384. <beans xmlns="http://www.springframework.org/schema/beans"
  385.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  386.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  387.     <bean id="vipBean" />
  388. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  389. <?xml version="1.0" encoding="UTF-8"?>
  390. <beans xmlns="http://www.springframework.org/schema/beans"
  391.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  392.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  393.     <bean id="vipBean" />
  394. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  395. <?xml version="1.0" encoding="UTF-8"?>
  396. <beans xmlns="http://www.springframework.org/schema/beans"
  397.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  398.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  399.     <bean id="vipBean" />
  400. </beans><bean id="userBean2" ></bean>
  401. <?xml version="1.0" encoding="UTF-8"?>
  402. <beans xmlns="http://www.springframework.org/schema/beans"
  403.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  404.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  405.     <bean id="vipBean" />
  406. </beans>
  407. </beans>return false;
  408. <?xml version="1.0" encoding="UTF-8"?>
  409. <beans xmlns="http://www.springframework.org/schema/beans"
  410.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  411.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  412.     <bean id="vipBean" />
  413. </beans>}
  414. }
  415. package com.powernode.oa.dao.impl;
  416. import com.powernode.oa.bean.User;
  417. import com.powernode.oa.dao.UserDao;
  418. public class UserDaoImplForMySQL implements UserDao {
  419. <?xml version="1.0" encoding="UTF-8"?>
  420. <beans xmlns="http://www.springframework.org/schema/beans"
  421.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  422.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  423.     <bean id="vipBean" />
  424. </beans>public User selectByUsernameAndPassword(String username, String password) {
  425. <?xml version="1.0" encoding="UTF-8"?>
  426. <beans xmlns="http://www.springframework.org/schema/beans"
  427. <?xml version="1.0" encoding="UTF-8"?>
  428. <beans xmlns="http://www.springframework.org/schema/beans"
  429.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  430.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  431.     <bean id="vipBean" />
  432. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  433. <?xml version="1.0" encoding="UTF-8"?>
  434. <beans xmlns="http://www.springframework.org/schema/beans"
  435.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  436.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  437.     <bean id="vipBean" />
  438. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  439. <?xml version="1.0" encoding="UTF-8"?>
  440. <beans xmlns="http://www.springframework.org/schema/beans"
  441.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  442.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  443.     <bean id="vipBean" />
  444. </beans><bean id="userBean2" ></bean>
  445. <?xml version="1.0" encoding="UTF-8"?>
  446. <beans xmlns="http://www.springframework.org/schema/beans"
  447.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  448.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  449.     <bean id="vipBean" />
  450. </beans>
  451. </beans>// 连接MySQL数据库,根据用户名和密码查询用户信息
  452. <?xml version="1.0" encoding="UTF-8"?>
  453. <beans xmlns="http://www.springframework.org/schema/beans"
  454. <?xml version="1.0" encoding="UTF-8"?>
  455. <beans xmlns="http://www.springframework.org/schema/beans"
  456.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  457.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  458.     <bean id="vipBean" />
  459. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  460. <?xml version="1.0" encoding="UTF-8"?>
  461. <beans xmlns="http://www.springframework.org/schema/beans"
  462.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  463.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  464.     <bean id="vipBean" />
  465. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  466. <?xml version="1.0" encoding="UTF-8"?>
  467. <beans xmlns="http://www.springframework.org/schema/beans"
  468.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  469.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  470.     <bean id="vipBean" />
  471. </beans><bean id="userBean2" ></bean>
  472. <?xml version="1.0" encoding="UTF-8"?>
  473. <beans xmlns="http://www.springframework.org/schema/beans"
  474.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  475.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  476.     <bean id="vipBean" />
  477. </beans>
  478. </beans>return null;
  479. <?xml version="1.0" encoding="UTF-8"?>
  480. <beans xmlns="http://www.springframework.org/schema/beans"
  481.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  482.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  483.     <bean id="vipBean" />
  484. </beans>}
  485. }
复制代码
可以看出,UserDaoImplForMySQL中主要是连接MySQL数据库进行操作。如果更换到Oracle数据库上,则需要再提供一个UserDaoImplForOracle,如下:
  1. package com.powernode.oa.dao.impl;
  2. import com.powernode.oa.bean.User;
  3. import com.powernode.oa.dao.UserDao;
  4. public class UserDaoImplForOracle implements UserDao {
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <beans xmlns="http://www.springframework.org/schema/beans"
  7.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  9.     <bean id="vipBean" />
  10. </beans>public User selectByUsernameAndPassword(String username, String password) {
  11. <?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans><bean id="userBean2" ></bean>
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>
  37. </beans>// 连接Oracle数据库,根据用户名和密码查询用户信息
  38. <?xml version="1.0" encoding="UTF-8"?>
  39. <beans xmlns="http://www.springframework.org/schema/beans"
  40. <?xml version="1.0" encoding="UTF-8"?>
  41. <beans xmlns="http://www.springframework.org/schema/beans"
  42.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  43.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  44.     <bean id="vipBean" />
  45. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  46. <?xml version="1.0" encoding="UTF-8"?>
  47. <beans xmlns="http://www.springframework.org/schema/beans"
  48.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  49.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  50.     <bean id="vipBean" />
  51. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  52. <?xml version="1.0" encoding="UTF-8"?>
  53. <beans xmlns="http://www.springframework.org/schema/beans"
  54.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  55.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  56.     <bean id="vipBean" />
  57. </beans><bean id="userBean2" ></bean>
  58. <?xml version="1.0" encoding="UTF-8"?>
  59. <beans xmlns="http://www.springframework.org/schema/beans"
  60.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  61.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  62.     <bean id="vipBean" />
  63. </beans>
  64. </beans>return null;
  65. <?xml version="1.0" encoding="UTF-8"?>
  66. <beans xmlns="http://www.springframework.org/schema/beans"
  67.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  68.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  69.     <bean id="vipBean" />
  70. </beans>}
  71. }
复制代码
很明显,以上的操作正在进行功能的扩展,添加了一个新的类UserDaoImplForOracle来应付数据库的变化,这里的变化会引起连锁反应吗?当然会,如果想要切换到Oracle数据库上,UserServiceImpl类代码就需要修改,如下:
  1. package com.powernode.oa.service.impl;
  2. import com.powernode.oa.bean.User;
  3. import com.powernode.oa.dao.UserDao;
  4. import com.powernode.oa.dao.impl.UserDaoImplForOracle;
  5. import com.powernode.oa.service.UserService;
  6. public class UserServiceImpl implements UserService {
  7. <?xml version="1.0" encoding="UTF-8"?>
  8. <beans xmlns="http://www.springframework.org/schema/beans"
  9.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  11.     <bean id="vipBean" />
  12. </beans>//private UserDao userDao = new UserDaoImplForMySQL();
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>private UserDao userDao = new UserDaoImplForOracle();
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>public boolean login(String username, String password) {
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27. <?xml version="1.0" encoding="UTF-8"?>
  28. <beans xmlns="http://www.springframework.org/schema/beans"
  29.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  30.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  31.     <bean id="vipBean" />
  32. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  33. <?xml version="1.0" encoding="UTF-8"?>
  34. <beans xmlns="http://www.springframework.org/schema/beans"
  35.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  36.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  37.     <bean id="vipBean" />
  38. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <beans xmlns="http://www.springframework.org/schema/beans"
  41.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  42.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43.     <bean id="vipBean" />
  44. </beans><bean id="userBean2" ></bean>
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <beans xmlns="http://www.springframework.org/schema/beans"
  47.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  49.     <bean id="vipBean" />
  50. </beans>
  51. </beans>User user = userDao.selectByUsernameAndPassword(username, password);
  52. <?xml version="1.0" encoding="UTF-8"?>
  53. <beans xmlns="http://www.springframework.org/schema/beans"
  54. <?xml version="1.0" encoding="UTF-8"?>
  55. <beans xmlns="http://www.springframework.org/schema/beans"
  56.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  57.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  58.     <bean id="vipBean" />
  59. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60. <?xml version="1.0" encoding="UTF-8"?>
  61. <beans xmlns="http://www.springframework.org/schema/beans"
  62.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  63.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  64.     <bean id="vipBean" />
  65. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  66. <?xml version="1.0" encoding="UTF-8"?>
  67. <beans xmlns="http://www.springframework.org/schema/beans"
  68.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  69.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  70.     <bean id="vipBean" />
  71. </beans><bean id="userBean2" ></bean>
  72. <?xml version="1.0" encoding="UTF-8"?>
  73. <beans xmlns="http://www.springframework.org/schema/beans"
  74.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  75.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  76.     <bean id="vipBean" />
  77. </beans>
  78. </beans>if (user != null) {
  79. <?xml version="1.0" encoding="UTF-8"?>
  80. <beans xmlns="http://www.springframework.org/schema/beans"
  81. <?xml version="1.0" encoding="UTF-8"?>
  82. <beans xmlns="http://www.springframework.org/schema/beans"
  83.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  84.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  85.     <bean id="vipBean" />
  86. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  87. <?xml version="1.0" encoding="UTF-8"?>
  88. <beans xmlns="http://www.springframework.org/schema/beans"
  89.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  90.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  91.     <bean id="vipBean" />
  92. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  93. <?xml version="1.0" encoding="UTF-8"?>
  94. <beans xmlns="http://www.springframework.org/schema/beans"
  95.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  96.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  97.     <bean id="vipBean" />
  98. </beans><bean id="userBean2" ></bean>
  99. <?xml version="1.0" encoding="UTF-8"?>
  100. <beans xmlns="http://www.springframework.org/schema/beans"
  101.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  102.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  103.     <bean id="vipBean" />
  104. </beans>
  105. </beans><?xml version="1.0" encoding="UTF-8"?>
  106. <beans xmlns="http://www.springframework.org/schema/beans"
  107.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  108.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  109.     <bean id="vipBean" />
  110. </beans>return true;
  111. <?xml version="1.0" encoding="UTF-8"?>
  112. <beans xmlns="http://www.springframework.org/schema/beans"
  113. <?xml version="1.0" encoding="UTF-8"?>
  114. <beans xmlns="http://www.springframework.org/schema/beans"
  115.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  116.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  117.     <bean id="vipBean" />
  118. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  119. <?xml version="1.0" encoding="UTF-8"?>
  120. <beans xmlns="http://www.springframework.org/schema/beans"
  121.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  122.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  123.     <bean id="vipBean" />
  124. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  125. <?xml version="1.0" encoding="UTF-8"?>
  126. <beans xmlns="http://www.springframework.org/schema/beans"
  127.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  128.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129.     <bean id="vipBean" />
  130. </beans><bean id="userBean2" ></bean>
  131. <?xml version="1.0" encoding="UTF-8"?>
  132. <beans xmlns="http://www.springframework.org/schema/beans"
  133.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  134.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  135.     <bean id="vipBean" />
  136. </beans>
  137. </beans>}
  138. <?xml version="1.0" encoding="UTF-8"?>
  139. <beans xmlns="http://www.springframework.org/schema/beans"
  140. <?xml version="1.0" encoding="UTF-8"?>
  141. <beans xmlns="http://www.springframework.org/schema/beans"
  142.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  143.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  144.     <bean id="vipBean" />
  145. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  146. <?xml version="1.0" encoding="UTF-8"?>
  147. <beans xmlns="http://www.springframework.org/schema/beans"
  148.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  149.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  150.     <bean id="vipBean" />
  151. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  152. <?xml version="1.0" encoding="UTF-8"?>
  153. <beans xmlns="http://www.springframework.org/schema/beans"
  154.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  155.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  156.     <bean id="vipBean" />
  157. </beans><bean id="userBean2" ></bean>
  158. <?xml version="1.0" encoding="UTF-8"?>
  159. <beans xmlns="http://www.springframework.org/schema/beans"
  160.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  161.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  162.     <bean id="vipBean" />
  163. </beans>
  164. </beans>return false;
  165. <?xml version="1.0" encoding="UTF-8"?>
  166. <beans xmlns="http://www.springframework.org/schema/beans"
  167.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  168.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  169.     <bean id="vipBean" />
  170. </beans>}
  171. }
复制代码
1.1 OCP开闭原则

这样一来就违背了开闭原则OCP。开闭原则是这样说的:在软件开发过程中应当对扩展开放,对修改关闭
也就是说,如果在进行功能扩展的时候,添加额外的类是没问题的,但因为功能扩展而修改之前运行正常的程序(代码),这是忌讳的,不被允许的。因为一旦修改之前运行正常的程序,就会导致项目整体要进行全方位的重新测试。这是相当麻烦的过程。导致以上问题的主要原因是:代码和代码之间的耦合度太高。如下图所示:

可以很明显的看出,上层是依赖下层的。UserController依赖UserServiceImpl,而UserServiceImpl依赖UserDaoImplForMySQL,这样就会导致下面只要改动上面必然会受牵连(跟着也会改),所谓牵一发而动全身。这样也就同时违背了另一个开发原则:依赖倒置原则。
1.2 依赖倒置原则DIP

依赖倒置原则(Dependence Inversion Principle),简称DIP,主要倡导面向抽象编程,面向接口编程,不要面向具体编程,让上层不再依赖下层,下面改动了,上面的代码不会受到牵连。这样可以大大降低程序的耦合度,耦合度低了,扩展力就强了,同时代码复用性也会增强。(软件七大开发原则都是在为解耦合服务
你可能会说,上面的代码已经面向接口编程了呀:

确实已经面向接口编程了,但对象的创建是:new UserDaoImplForOracle()显然并没有完全面向接口编程,还是使用到了具体的接口实现类。什么叫做完全面向接口编程?什么叫做完全符合依赖倒置原则呢?请看以下代码:

如果代码是这样编写的,才算是完全面向接口编程,才符合依赖倒置原则。那你可能会问,这样userDao是null,在执行的时候就会出现空指针异常呀。你说的有道理,确实是这样的,所以我们要解决这个问题。解决空指针异常的问题,其实就是解决两个核心的问题:
如果我们把以上两个核心问题解决了,就可以做到既符合OCP开闭原则,又符合依赖倒置原则。
很荣幸的通知你:Spring框架可以做到。
在Spring框架中,它可以帮助我们new对象,并且它还可以将new出来的对象赋到属性上。换句话说,Spring框架可以帮助我们创建对象,并且可以帮助我们维护对象和对象之间的关系。比如:

Spring可以new出来UserDaoImplForMySQL对象,也可以new出来UserDaoImplForOracle对象,并且还可以让new出来的dao对象和service对象产生关系(产生关系其实本质上就是给属性赋值)。
很显然,这种方式是将对象的创建权/管理权交出去了,不再使用硬编码的方式了。同时也把对象关系的管理权交出去了,也不再使用硬编码的方式了。像这种把对象的创建权交出去,把对象关系的管理权交出去,被称为控制反转。
1.3 控制反转IoC

控制反转(Inversion of Control,缩写为IoC),是面向对象编程中的一种设计思想,可以用来降低代码之间的耦合度,符合依赖倒置原则。
控制反转的核心是:将对象的创建权交出去,将对象和对象之间关系的管理权交出去,由第三方容器来负责创建与维护。简单的说:就是可以帮你创建对象(new 对象)这个步骤:不需要你手动的 new 对象了。
控制反转常见的实现方式:依赖注入(Dependency Injection,简称DI)
通常,依赖注入的实现由包括两种方式:
而Spring框架就是一个实现了IoC思想的框架。
IoC可以认为是一种全新的设计模式,但是理论和时间成熟相对较晚,并没有包含在GoF中。(GoF指的是23种设计模式)
2. Spring 初始


Spring 是一个开源框架,它由Rod Johnson 创建。它是为了解决企业应用开发的复杂性而创建的
从简单性,可测试性和松耦合的角度而言,任何Java应用都可以从 Spring 中收益。
Spring 是一种轻量级的控制反转(IOC) 和面向切面(ADP) 的容器框架。
Spring 最初的出现是为了解决EJB隆肿的设计,以及难以测试等问题。
Spring 为此简化开发而生,让程序员只需关注核心业务的实现,尽可能的不再关注非业务逻辑代码(事务控制,安全日志等)
注意:Spring5版本之后是8个模块。在Spring5中新增了WebFlux模块。

这是Spring框架最基础的部分,它提供了依赖注入(DependencyInjection)特征来实现容器对Bean的管理。核心容器的主要组件是 BeanFactory,BeanFactory是工厂模式的一个实现,是任何Spring应用的核心。它使用IoC将应用配置和依赖从实际的应用代码中分离出来。
如果说核心模块中的BeanFactory使Spring成为容器的话,那么上下文模块就是Spring成为框架的原因。
这个模块扩展了BeanFactory,增加了对国际化(I18N)消息、事件传播、验证的支持。另外提供了许多企业服务,例如电子邮件、JNDI访问、EJB集成、远程以及时序调度(scheduling)服务。也包括了对模版框架例如Velocity和FreeMarker集成的支持
Spring在它的AOP模块中提供了对面向切面编程的丰富支持,Spring AOP 模块为基于 Spring 的应用程序中的对象提供了事务管理服务。通过使用 Spring AOP,不用依赖组件,就可以将声明性事务管理集成到应用程序中,可以自定义拦截器、切点、日志等操作。
提供了一个JDBC的抽象层和异常层次结构,消除了烦琐的JDBC编码和数据库厂商特有的错误代码解析,用于简化JDBC。
Spring提供了ORM模块。Spring并不试图实现它自己的ORM解决方案,而是为几种流行的ORM框架提供了集成方案,包括Hibernate、JDO和iBATIS SQL映射,这些都遵从 Spring 的通用事务和 DAO 异常层次结构。
Spring为构建Web应用提供了一个功能全面的MVC框架。虽然Spring可以很容易地与其它MVC框架集成,例如Struts,但Spring的MVC框架使用IoC对控制逻辑和业务对象提供了完全的分离。
Spring Framework 中包含的原始 Web 框架 Spring Web MVC 是专门为 Servlet API 和 Servlet 容器构建的。反应式堆栈 Web 框架 Spring WebFlux 是在 5.0 版的后期添加的。它是完全非阻塞的,支持反应式流(Reactive Stream)背压,并在Netty,Undertow和Servlet 3.1+容器等服务器上运行。

Web 上下文模块建立在应用程序上下文模块之上,为基于 Web 的应用程序提供了上下文,提供了Spring和其它Web框架的集成,比如Struts、WebWork。还提供了一些面向服务支持,例如:实现文件上传的multipart请求。
2.1 Spring特点

所有Spring的这些特征使你能够编写更干净、更可管理、并且更易于测试的代码。它们也为Spring中的各种模块提供了基础支持。
2.2 Spring6 的下载:

官网地址:https://spring.io/

官网地址(中文):http://spring.p2hp.com/

打开Spring官网后,可以看到Spring Framework,以及通过Spring Framework衍生的其它框架:

我们即将要学习的就是Spring Framework。
怎么下载呢?







点击spring-5.3.9-dist.zip下载spring框架。
将下载的zip包解压:

docs:spring框架的API帮助文档
libs:spring框架的jar文件(用spring框架就是用这些jar包
schema:spring框架的XML配置文件相关的约束文件
2.3 Spring的jar文件

打开libs目录,会看到很多jar包:

spring-core-5.3.9.jar:字节码(这个是支撑程序运行的jar包
spring-core-5.3.9-javadoc.jar:代码中的注释
spring-core-5.3.9-sources.jar:源码
我们来看一下spring框架都有哪些jar包:

JAR文件描述spring-aop-5.3.9.jar这个jar 文件包含在应用中使用Spring 的AOP 特性时所需的类spring-aspects-5.3.9.jar提供对AspectJ的支持,以便可以方便的将面向切面的功能集成进IDE中spring-beans-5.3.9.jar这个jar 文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean 以及进行Inversion ofControl / Dependency Injection(IoC/DI)操作相关的所有类。如果应用只需基本的IoC/DI 支持,引入spring-core.jar 及spring-beans.jar 文件就可以了。spring-context-5.3.9.jar这个jar 文件为Spring 核心提供了大量扩展。可以找到使用Spring ApplicationContext特性时所需的全部类,JDNI 所需的全部类,instrumentation组件以及校验Validation 方面的相关类。spring-context-indexer-5.3.9.jar虽然类路径扫描非常快,但是Spring内部存在大量的类,添加此依赖,可以通过在编译时创建候选对象的静态列表来提高大型应用程序的启动性能。spring-context-support-5.3.9.jar用来提供Spring上下文的一些扩展模块,例如实现邮件服务、视图解析、缓存、定时任务调度等spring-core-5.3.9.jarSpring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具类。spring-expression-5.3.9.jarSpring表达式语言。spring-instrument-5.3.9.jarSpring3.0对服务器的代理接口。spring-jcl-5.3.9.jarSpring的日志模块。JCL,全称为"Jakarta Commons Logging",也可称为"Apache Commons Logging"。spring-jdbc-5.3.9.jarSpring对JDBC的支持。spring-jms-5.3.9.jar这个jar包提供了对JMS 1.0.2/1.1的支持类。JMS是Java消息服务。属于JavaEE规范之一。spring-messaging-5.3.9.jar为集成messaging api和消息协议提供支持spring-orm-5.3.9.jarSpring集成ORM框架的支持,比如集成hibernate,mybatis等。spring-oxm-5.3.9.jar为主流O/X Mapping组件提供了统一层抽象和封装,OXM是Object Xml Mapping。对象和XML之间的相互转换。spring-r2dbc-5.3.9.jarReactive Relational Database Connectivity (关系型数据库的响应式连接) 的缩写。这个jar文件是Spring对r2dbc的支持。spring-test-5.3.9.jar对Junit等测试框架的简单封装。spring-tx-5.3.9.jar为JDBC、Hibernate、JDO、JPA、Beans等提供的一致的声明式和编程式事务管理支持。spring-web-5.3.9.jarSpring集成MVC框架的支持,比如集成Struts等。spring-webflux-5.3.9.jarWebFlux是 Spring5 添加的新模块,用于 web 的开发,功能和 SpringMVC 类似的,Webflux 使用当前一种比较流程响应式编程出现的框架。spring-webmvc-5.3.9.jarSpringMVC框架的类库spring-websocket-5.3.9.jarSpring集成WebSocket框架时使用这里我们不是使用上面的方式下载的: 而是通过:Maven 自动化管理工具:
  1.   
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. <?xml version="1.0" encoding="UTF-8"?>
  5. <beans xmlns="http://www.springframework.org/schema/beans"
  6.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  8.     <bean id="vipBean" />
  9. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. <?xml version="1.0" encoding="UTF-8"?>
  11. <beans xmlns="http://www.springframework.org/schema/beans"
  12.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  13.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  14.     <bean id="vipBean" />
  15. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  16. <?xml version="1.0" encoding="UTF-8"?>
  17. <beans xmlns="http://www.springframework.org/schema/beans"
  18.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20.     <bean id="vipBean" />
  21. </beans><bean id="userBean2" ></bean>
  22. <?xml version="1.0" encoding="UTF-8"?>
  23. <beans xmlns="http://www.springframework.org/schema/beans"
  24.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  25.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  26.     <bean id="vipBean" />
  27. </beans>
  28. </beans>
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41.     <bean id="vipBean" />
  42. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <beans xmlns="http://www.springframework.org/schema/beans"
  45.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  46.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  47.     <bean id="vipBean" />
  48. </beans><bean id="userBean2" ></bean>
  49. <?xml version="1.0" encoding="UTF-8"?>
  50. <beans xmlns="http://www.springframework.org/schema/beans"
  51.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  52.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  53.     <bean id="vipBean" />
  54. </beans>
  55. </beans>
  56. <?xml version="1.0" encoding="UTF-8"?>
  57. <beans xmlns="http://www.springframework.org/schema/beans"
  58. <?xml version="1.0" encoding="UTF-8"?>
  59. <beans xmlns="http://www.springframework.org/schema/beans"
  60.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  61.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  62.     <bean id="vipBean" />
  63. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  64. <?xml version="1.0" encoding="UTF-8"?>
  65. <beans xmlns="http://www.springframework.org/schema/beans"
  66.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  67.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  68.     <bean id="vipBean" />
  69. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  70. <?xml version="1.0" encoding="UTF-8"?>
  71. <beans xmlns="http://www.springframework.org/schema/beans"
  72.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  73.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  74.     <bean id="vipBean" />
  75. </beans><bean id="userBean2" ></bean>
  76. <?xml version="1.0" encoding="UTF-8"?>
  77. <beans xmlns="http://www.springframework.org/schema/beans"
  78.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  79.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  80.     <bean id="vipBean" />
  81. </beans>
  82. </beans><dependency>
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85. <?xml version="1.0" encoding="UTF-8"?>
  86. <beans xmlns="http://www.springframework.org/schema/beans"
  87.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  88.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  89.     <bean id="vipBean" />
  90. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <beans xmlns="http://www.springframework.org/schema/beans"
  99.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  101.     <bean id="vipBean" />
  102. </beans><bean id="userBean2" ></bean>
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  107.     <bean id="vipBean" />
  108. </beans>
  109. </beans><?xml version="1.0" encoding="UTF-8"?>
  110. <beans xmlns="http://www.springframework.org/schema/beans"
  111.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  113.     <bean id="vipBean" />
  114. </beans><groupId>org.springframework</groupId>
  115. <?xml version="1.0" encoding="UTF-8"?>
  116. <beans xmlns="http://www.springframework.org/schema/beans"
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><bean id="userBean2" ></bean>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139.     <bean id="vipBean" />
  140. </beans>
  141. </beans><?xml version="1.0" encoding="UTF-8"?>
  142. <beans xmlns="http://www.springframework.org/schema/beans"
  143.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  144.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  145.     <bean id="vipBean" />
  146. </beans><artifactId>spring-context</artifactId>
  147. <?xml version="1.0" encoding="UTF-8"?>
  148. <beans xmlns="http://www.springframework.org/schema/beans"
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  161. <?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans><bean id="userBean2" ></bean>
  167. <?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  170.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  171.     <bean id="vipBean" />
  172. </beans>
  173. </beans><?xml version="1.0" encoding="UTF-8"?>
  174. <beans xmlns="http://www.springframework.org/schema/beans"
  175.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  176.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  177.     <bean id="vipBean" />
  178. </beans><version>6.0.3</version>
  179. <?xml version="1.0" encoding="UTF-8"?>
  180. <beans xmlns="http://www.springframework.org/schema/beans"
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  193. <?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  196.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  197.     <bean id="vipBean" />
  198. </beans><bean id="userBean2" ></bean>
  199. <?xml version="1.0" encoding="UTF-8"?>
  200. <beans xmlns="http://www.springframework.org/schema/beans"
  201.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  202.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  203.     <bean id="vipBean" />
  204. </beans>
  205. </beans></dependency>
复制代码
注意:如果你只是想用Spring的IoC功能,仅需要引入:spring-context即可。将这个jar包添加到classpath当中。
如果采用maven只需要引入context的依赖即可。
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>  repository.spring.milestone<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  10.     <bean id="vipBean" />
  11. </beans>Spring Milestone Repository<?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15.     <bean id="vipBean" />
  16. </beans>https://repo.spring.io/milestone<?xml version="1.0" encoding="UTF-8"?>
  17. <beans xmlns="http://www.springframework.org/schema/beans"
  18.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20.     <bean id="vipBean" />
  21. </beans>
  22. <?xml version="1.0" encoding="UTF-8"?>
  23. <beans xmlns="http://www.springframework.org/schema/beans"
  24. <?xml version="1.0" encoding="UTF-8"?>
  25. <beans xmlns="http://www.springframework.org/schema/beans"
  26.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  27.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  28.     <bean id="vipBean" />
  29. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  30. <?xml version="1.0" encoding="UTF-8"?>
  31. <beans xmlns="http://www.springframework.org/schema/beans"
  32.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  33.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  34.     <bean id="vipBean" />
  35. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  36. <?xml version="1.0" encoding="UTF-8"?>
  37. <beans xmlns="http://www.springframework.org/schema/beans"
  38.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  39.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  40.     <bean id="vipBean" />
  41. </beans><bean id="userBean2" ></bean>
  42. <?xml version="1.0" encoding="UTF-8"?>
  43. <beans xmlns="http://www.springframework.org/schema/beans"
  44.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  45.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  46.     <bean id="vipBean" />
  47. </beans>
  48. </beans>
  49. <?xml version="1.0" encoding="UTF-8"?>
  50. <beans xmlns="http://www.springframework.org/schema/beans"
  51. <?xml version="1.0" encoding="UTF-8"?>
  52. <beans xmlns="http://www.springframework.org/schema/beans"
  53.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  55.     <bean id="vipBean" />
  56. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  57. <?xml version="1.0" encoding="UTF-8"?>
  58. <beans xmlns="http://www.springframework.org/schema/beans"
  59.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61.     <bean id="vipBean" />
  62. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  63. <?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  66.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  67.     <bean id="vipBean" />
  68. </beans><bean id="userBean2" ></bean>
  69. <?xml version="1.0" encoding="UTF-8"?>
  70. <beans xmlns="http://www.springframework.org/schema/beans"
  71.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  72.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  73.     <bean id="vipBean" />
  74. </beans>
  75. </beans>
  76. <?xml version="1.0" encoding="UTF-8"?>
  77. <beans xmlns="http://www.springframework.org/schema/beans"
  78. <?xml version="1.0" encoding="UTF-8"?>
  79. <beans xmlns="http://www.springframework.org/schema/beans"
  80.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  81.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  82.     <bean id="vipBean" />
  83. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  84. <?xml version="1.0" encoding="UTF-8"?>
  85. <beans xmlns="http://www.springframework.org/schema/beans"
  86.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  87.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  88.     <bean id="vipBean" />
  89. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  90. <?xml version="1.0" encoding="UTF-8"?>
  91. <beans xmlns="http://www.springframework.org/schema/beans"
  92.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  93.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  94.     <bean id="vipBean" />
  95. </beans><bean id="userBean2" ></bean>
  96. <?xml version="1.0" encoding="UTF-8"?>
  97. <beans xmlns="http://www.springframework.org/schema/beans"
  98.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  99.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  100.     <bean id="vipBean" />
  101. </beans>
  102. </beans><dependency>
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105. <?xml version="1.0" encoding="UTF-8"?>
  106. <beans xmlns="http://www.springframework.org/schema/beans"
  107.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  108.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  109.     <bean id="vipBean" />
  110. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  111. <?xml version="1.0" encoding="UTF-8"?>
  112. <beans xmlns="http://www.springframework.org/schema/beans"
  113.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  114.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  115.     <bean id="vipBean" />
  116. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans><bean id="userBean2" ></bean>
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>
  129. </beans><?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><groupId>org.springframework</groupId>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137. <?xml version="1.0" encoding="UTF-8"?>
  138. <beans xmlns="http://www.springframework.org/schema/beans"
  139.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  140.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  141.     <bean id="vipBean" />
  142. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  143. <?xml version="1.0" encoding="UTF-8"?>
  144. <beans xmlns="http://www.springframework.org/schema/beans"
  145.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  146.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  147.     <bean id="vipBean" />
  148. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans><bean id="userBean2" ></bean>
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans>
  161. </beans><?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans><artifactId>spring-context</artifactId>
  167. <?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169. <?xml version="1.0" encoding="UTF-8"?>
  170. <beans xmlns="http://www.springframework.org/schema/beans"
  171.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  172.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  173.     <bean id="vipBean" />
  174. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  175. <?xml version="1.0" encoding="UTF-8"?>
  176. <beans xmlns="http://www.springframework.org/schema/beans"
  177.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  178.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  179.     <bean id="vipBean" />
  180. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans><bean id="userBean2" ></bean>
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>
  193. </beans><?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  196.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  197.     <bean id="vipBean" />
  198. </beans><version>6.0.3</version>
  199. <?xml version="1.0" encoding="UTF-8"?>
  200. <beans xmlns="http://www.springframework.org/schema/beans"
  201. <?xml version="1.0" encoding="UTF-8"?>
  202. <beans xmlns="http://www.springframework.org/schema/beans"
  203.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  204.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  205.     <bean id="vipBean" />
  206. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  207. <?xml version="1.0" encoding="UTF-8"?>
  208. <beans xmlns="http://www.springframework.org/schema/beans"
  209.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  210.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  211.     <bean id="vipBean" />
  212. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  213. <?xml version="1.0" encoding="UTF-8"?>
  214. <beans xmlns="http://www.springframework.org/schema/beans"
  215.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  216.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  217.     <bean id="vipBean" />
  218. </beans><bean id="userBean2" ></bean>
  219. <?xml version="1.0" encoding="UTF-8"?>
  220. <beans xmlns="http://www.springframework.org/schema/beans"
  221.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  222.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  223.     <bean id="vipBean" />
  224. </beans>
  225. </beans></dependency>
复制代码
3. 第一个Spring 程序的编写


配置该项目的 JDK为 17
注意的是: 对应 Spring6 来说:最低支持的是 JDK17 ,低于 17 的版本是不行的,所以如果你要想使用 Spring6 框架的话,必须安装 JDK > = 17 的版本才行。

第一步:配置好该项目中的Maven本地路径信息:


第二步:添加spring context的依赖,pom.xml配置如下
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>4.0.0<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  10.     <bean id="vipBean" />
  11. </beans>com.raibowsea<?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15.     <bean id="vipBean" />
  16. </beans>spring6-003-dependency-injection<?xml version="1.0" encoding="UTF-8"?>
  17. <beans xmlns="http://www.springframework.org/schema/beans"
  18.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20.     <bean id="vipBean" />
  21. </beans>1.0-SNAPSHOT<?xml version="1.0" encoding="UTF-8"?>
  22. <beans xmlns="http://www.springframework.org/schema/beans"
  23. <?xml version="1.0" encoding="UTF-8"?>
  24. <beans xmlns="http://www.springframework.org/schema/beans"
  25.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  26.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  27.     <bean id="vipBean" />
  28. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  32.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  33.     <bean id="vipBean" />
  34. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <beans xmlns="http://www.springframework.org/schema/beans"
  37.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  39.     <bean id="vipBean" />
  40. </beans><bean id="userBean2" ></bean>
  41. <?xml version="1.0" encoding="UTF-8"?>
  42. <beans xmlns="http://www.springframework.org/schema/beans"
  43.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  45.     <bean id="vipBean" />
  46. </beans>
  47. </beans>jar<?xml version="1.0" encoding="UTF-8"?>
  48. <beans xmlns="http://www.springframework.org/schema/beans"
  49. <?xml version="1.0" encoding="UTF-8"?>
  50. <beans xmlns="http://www.springframework.org/schema/beans"
  51.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  52.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  53.     <bean id="vipBean" />
  54. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  55. <?xml version="1.0" encoding="UTF-8"?>
  56. <beans xmlns="http://www.springframework.org/schema/beans"
  57.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  58.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  59.     <bean id="vipBean" />
  60. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61. <?xml version="1.0" encoding="UTF-8"?>
  62. <beans xmlns="http://www.springframework.org/schema/beans"
  63.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  64.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  65.     <bean id="vipBean" />
  66. </beans><bean id="userBean2" ></bean>
  67. <?xml version="1.0" encoding="UTF-8"?>
  68. <beans xmlns="http://www.springframework.org/schema/beans"
  69.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  70.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  71.     <bean id="vipBean" />
  72. </beans>
  73. </beans><?xml version="1.0" encoding="UTF-8"?>
  74. <beans xmlns="http://www.springframework.org/schema/beans"
  75.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  76.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77.     <bean id="vipBean" />
  78. </beans>17<?xml version="1.0" encoding="UTF-8"?>
  79. <beans xmlns="http://www.springframework.org/schema/beans"
  80. <?xml version="1.0" encoding="UTF-8"?>
  81. <beans xmlns="http://www.springframework.org/schema/beans"
  82.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  83.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  84.     <bean id="vipBean" />
  85. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86. <?xml version="1.0" encoding="UTF-8"?>
  87. <beans xmlns="http://www.springframework.org/schema/beans"
  88.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  89.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  90.     <bean id="vipBean" />
  91. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  92. <?xml version="1.0" encoding="UTF-8"?>
  93. <beans xmlns="http://www.springframework.org/schema/beans"
  94.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  95.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  96.     <bean id="vipBean" />
  97. </beans><bean id="userBean2" ></bean>
  98. <?xml version="1.0" encoding="UTF-8"?>
  99. <beans xmlns="http://www.springframework.org/schema/beans"
  100.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  101.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  102.     <bean id="vipBean" />
  103. </beans>
  104. </beans>17<?xml version="1.0" encoding="UTF-8"?>
  105. <beans xmlns="http://www.springframework.org/schema/beans"
  106. <?xml version="1.0" encoding="UTF-8"?>
  107. <beans xmlns="http://www.springframework.org/schema/beans"
  108.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  109.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  110.     <bean id="vipBean" />
  111. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112. <?xml version="1.0" encoding="UTF-8"?>
  113. <beans xmlns="http://www.springframework.org/schema/beans"
  114.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  115.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  116.     <bean id="vipBean" />
  117. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  118. <?xml version="1.0" encoding="UTF-8"?>
  119. <beans xmlns="http://www.springframework.org/schema/beans"
  120.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  121.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  122.     <bean id="vipBean" />
  123. </beans><bean id="userBean2" ></bean>
  124. <?xml version="1.0" encoding="UTF-8"?>
  125. <beans xmlns="http://www.springframework.org/schema/beans"
  126.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  127.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  128.     <bean id="vipBean" />
  129. </beans>
  130. </beans><?xml version="1.0" encoding="UTF-8"?>
  131. <beans xmlns="http://www.springframework.org/schema/beans"
  132. <?xml version="1.0" encoding="UTF-8"?>
  133. <beans xmlns="http://www.springframework.org/schema/beans"
  134.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  135.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  136.     <bean id="vipBean" />
  137. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138. <?xml version="1.0" encoding="UTF-8"?>
  139. <beans xmlns="http://www.springframework.org/schema/beans"
  140.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  141.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  142.     <bean id="vipBean" />
  143. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  144. <?xml version="1.0" encoding="UTF-8"?>
  145. <beans xmlns="http://www.springframework.org/schema/beans"
  146.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  147.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  148.     <bean id="vipBean" />
  149. </beans><bean id="userBean2" ></bean>
  150. <?xml version="1.0" encoding="UTF-8"?>
  151. <beans xmlns="http://www.springframework.org/schema/beans"
  152.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  153.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  154.     <bean id="vipBean" />
  155. </beans>
  156. </beans><?xml version="1.0" encoding="UTF-8"?>
  157. <beans xmlns="http://www.springframework.org/schema/beans"
  158.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  159.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  160.     <bean id="vipBean" />
  161. </beans>
  162. <?xml version="1.0" encoding="UTF-8"?>
  163. <beans xmlns="http://www.springframework.org/schema/beans"
  164. <?xml version="1.0" encoding="UTF-8"?>
  165. <beans xmlns="http://www.springframework.org/schema/beans"
  166.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  167.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  168.     <bean id="vipBean" />
  169. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  170. <?xml version="1.0" encoding="UTF-8"?>
  171. <beans xmlns="http://www.springframework.org/schema/beans"
  172.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  173.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  174.     <bean id="vipBean" />
  175. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  176. <?xml version="1.0" encoding="UTF-8"?>
  177. <beans xmlns="http://www.springframework.org/schema/beans"
  178.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  179.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  180.     <bean id="vipBean" />
  181. </beans><bean id="userBean2" ></bean>
  182. <?xml version="1.0" encoding="UTF-8"?>
  183. <beans xmlns="http://www.springframework.org/schema/beans"
  184.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  185.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  186.     <bean id="vipBean" />
  187. </beans>
  188. </beans>
  189. <?xml version="1.0" encoding="UTF-8"?>
  190. <beans xmlns="http://www.springframework.org/schema/beans"
  191. <?xml version="1.0" encoding="UTF-8"?>
  192. <beans xmlns="http://www.springframework.org/schema/beans"
  193.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  194.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  195.     <bean id="vipBean" />
  196. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  197. <?xml version="1.0" encoding="UTF-8"?>
  198. <beans xmlns="http://www.springframework.org/schema/beans"
  199.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  200.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  201.     <bean id="vipBean" />
  202. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  203. <?xml version="1.0" encoding="UTF-8"?>
  204. <beans xmlns="http://www.springframework.org/schema/beans"
  205.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  206.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  207.     <bean id="vipBean" />
  208. </beans><bean id="userBean2" ></bean>
  209. <?xml version="1.0" encoding="UTF-8"?>
  210. <beans xmlns="http://www.springframework.org/schema/beans"
  211.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  212.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  213.     <bean id="vipBean" />
  214. </beans>
  215. </beans>
  216. <?xml version="1.0" encoding="UTF-8"?>
  217. <beans xmlns="http://www.springframework.org/schema/beans"
  218. <?xml version="1.0" encoding="UTF-8"?>
  219. <beans xmlns="http://www.springframework.org/schema/beans"
  220.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  221.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  222.     <bean id="vipBean" />
  223. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  224. <?xml version="1.0" encoding="UTF-8"?>
  225. <beans xmlns="http://www.springframework.org/schema/beans"
  226.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  227.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  228.     <bean id="vipBean" />
  229. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  230. <?xml version="1.0" encoding="UTF-8"?>
  231. <beans xmlns="http://www.springframework.org/schema/beans"
  232.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  233.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  234.     <bean id="vipBean" />
  235. </beans><bean id="userBean2" ></bean>
  236. <?xml version="1.0" encoding="UTF-8"?>
  237. <beans xmlns="http://www.springframework.org/schema/beans"
  238.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  239.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  240.     <bean id="vipBean" />
  241. </beans>
  242. </beans><dependency>
  243. <?xml version="1.0" encoding="UTF-8"?>
  244. <beans xmlns="http://www.springframework.org/schema/beans"
  245. <?xml version="1.0" encoding="UTF-8"?>
  246. <beans xmlns="http://www.springframework.org/schema/beans"
  247.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  248.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  249.     <bean id="vipBean" />
  250. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  251. <?xml version="1.0" encoding="UTF-8"?>
  252. <beans xmlns="http://www.springframework.org/schema/beans"
  253.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  254.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  255.     <bean id="vipBean" />
  256. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  257. <?xml version="1.0" encoding="UTF-8"?>
  258. <beans xmlns="http://www.springframework.org/schema/beans"
  259.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  260.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  261.     <bean id="vipBean" />
  262. </beans><bean id="userBean2" ></bean>
  263. <?xml version="1.0" encoding="UTF-8"?>
  264. <beans xmlns="http://www.springframework.org/schema/beans"
  265.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  266.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  267.     <bean id="vipBean" />
  268. </beans>
  269. </beans><?xml version="1.0" encoding="UTF-8"?>
  270. <beans xmlns="http://www.springframework.org/schema/beans"
  271.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  272.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  273.     <bean id="vipBean" />
  274. </beans><groupId>org.springframework</groupId>
  275. <?xml version="1.0" encoding="UTF-8"?>
  276. <beans xmlns="http://www.springframework.org/schema/beans"
  277. <?xml version="1.0" encoding="UTF-8"?>
  278. <beans xmlns="http://www.springframework.org/schema/beans"
  279.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  280.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  281.     <bean id="vipBean" />
  282. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  283. <?xml version="1.0" encoding="UTF-8"?>
  284. <beans xmlns="http://www.springframework.org/schema/beans"
  285.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  286.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  287.     <bean id="vipBean" />
  288. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  289. <?xml version="1.0" encoding="UTF-8"?>
  290. <beans xmlns="http://www.springframework.org/schema/beans"
  291.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  292.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  293.     <bean id="vipBean" />
  294. </beans><bean id="userBean2" ></bean>
  295. <?xml version="1.0" encoding="UTF-8"?>
  296. <beans xmlns="http://www.springframework.org/schema/beans"
  297.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  298.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  299.     <bean id="vipBean" />
  300. </beans>
  301. </beans><?xml version="1.0" encoding="UTF-8"?>
  302. <beans xmlns="http://www.springframework.org/schema/beans"
  303.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  304.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  305.     <bean id="vipBean" />
  306. </beans><artifactId>spring-context</artifactId>
  307. <?xml version="1.0" encoding="UTF-8"?>
  308. <beans xmlns="http://www.springframework.org/schema/beans"
  309. <?xml version="1.0" encoding="UTF-8"?>
  310. <beans xmlns="http://www.springframework.org/schema/beans"
  311.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  312.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  313.     <bean id="vipBean" />
  314. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  315. <?xml version="1.0" encoding="UTF-8"?>
  316. <beans xmlns="http://www.springframework.org/schema/beans"
  317.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  318.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  319.     <bean id="vipBean" />
  320. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  321. <?xml version="1.0" encoding="UTF-8"?>
  322. <beans xmlns="http://www.springframework.org/schema/beans"
  323.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  324.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  325.     <bean id="vipBean" />
  326. </beans><bean id="userBean2" ></bean>
  327. <?xml version="1.0" encoding="UTF-8"?>
  328. <beans xmlns="http://www.springframework.org/schema/beans"
  329.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  330.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  331.     <bean id="vipBean" />
  332. </beans>
  333. </beans><?xml version="1.0" encoding="UTF-8"?>
  334. <beans xmlns="http://www.springframework.org/schema/beans"
  335.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  336.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  337.     <bean id="vipBean" />
  338. </beans><version>6.0.3</version>
  339. <?xml version="1.0" encoding="UTF-8"?>
  340. <beans xmlns="http://www.springframework.org/schema/beans"
  341. <?xml version="1.0" encoding="UTF-8"?>
  342. <beans xmlns="http://www.springframework.org/schema/beans"
  343.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  344.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  345.     <bean id="vipBean" />
  346. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  347. <?xml version="1.0" encoding="UTF-8"?>
  348. <beans xmlns="http://www.springframework.org/schema/beans"
  349.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  350.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  351.     <bean id="vipBean" />
  352. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  353. <?xml version="1.0" encoding="UTF-8"?>
  354. <beans xmlns="http://www.springframework.org/schema/beans"
  355.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  356.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  357.     <bean id="vipBean" />
  358. </beans><bean id="userBean2" ></bean>
  359. <?xml version="1.0" encoding="UTF-8"?>
  360. <beans xmlns="http://www.springframework.org/schema/beans"
  361.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  362.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  363.     <bean id="vipBean" />
  364. </beans>
  365. </beans></dependency><?xml version="1.0" encoding="UTF-8"?>
  366. <beans xmlns="http://www.springframework.org/schema/beans"
  367. <?xml version="1.0" encoding="UTF-8"?>
  368. <beans xmlns="http://www.springframework.org/schema/beans"
  369.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  370.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  371.     <bean id="vipBean" />
  372. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  373. <?xml version="1.0" encoding="UTF-8"?>
  374. <beans xmlns="http://www.springframework.org/schema/beans"
  375.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  376.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  377.     <bean id="vipBean" />
  378. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  379. <?xml version="1.0" encoding="UTF-8"?>
  380. <beans xmlns="http://www.springframework.org/schema/beans"
  381.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  382.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  383.     <bean id="vipBean" />
  384. </beans><bean id="userBean2" ></bean>
  385. <?xml version="1.0" encoding="UTF-8"?>
  386. <beans xmlns="http://www.springframework.org/schema/beans"
  387.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  388.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  389.     <bean id="vipBean" />
  390. </beans>
  391. </beans><?xml version="1.0" encoding="UTF-8"?>
  392. <beans xmlns="http://www.springframework.org/schema/beans"
  393. <?xml version="1.0" encoding="UTF-8"?>
  394. <beans xmlns="http://www.springframework.org/schema/beans"
  395.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  396.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  397.     <bean id="vipBean" />
  398. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  399. <?xml version="1.0" encoding="UTF-8"?>
  400. <beans xmlns="http://www.springframework.org/schema/beans"
  401.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  402.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  403.     <bean id="vipBean" />
  404. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  405. <?xml version="1.0" encoding="UTF-8"?>
  406. <beans xmlns="http://www.springframework.org/schema/beans"
  407.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  408.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  409.     <bean id="vipBean" />
  410. </beans><bean id="userBean2" ></bean>
  411. <?xml version="1.0" encoding="UTF-8"?>
  412. <beans xmlns="http://www.springframework.org/schema/beans"
  413.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  414.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  415.     <bean id="vipBean" />
  416. </beans>
  417. </beans><?xml version="1.0" encoding="UTF-8"?>
  418. <beans xmlns="http://www.springframework.org/schema/beans"
  419. <?xml version="1.0" encoding="UTF-8"?>
  420. <beans xmlns="http://www.springframework.org/schema/beans"
  421.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  422.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  423.     <bean id="vipBean" />
  424. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  425. <?xml version="1.0" encoding="UTF-8"?>
  426. <beans xmlns="http://www.springframework.org/schema/beans"
  427.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  428.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  429.     <bean id="vipBean" />
  430. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  431. <?xml version="1.0" encoding="UTF-8"?>
  432. <beans xmlns="http://www.springframework.org/schema/beans"
  433.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  434.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  435.     <bean id="vipBean" />
  436. </beans><bean id="userBean2" ></bean>
  437. <?xml version="1.0" encoding="UTF-8"?>
  438. <beans xmlns="http://www.springframework.org/schema/beans"
  439.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  440.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  441.     <bean id="vipBean" />
  442. </beans>
  443. </beans><?xml version="1.0" encoding="UTF-8"?>
  444. <beans xmlns="http://www.springframework.org/schema/beans"
  445.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  446.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  447.     <bean id="vipBean" />
  448. </beans>junit<?xml version="1.0" encoding="UTF-8"?>
  449. <beans xmlns="http://www.springframework.org/schema/beans"
  450. <?xml version="1.0" encoding="UTF-8"?>
  451. <beans xmlns="http://www.springframework.org/schema/beans"
  452.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  453.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  454.     <bean id="vipBean" />
  455. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  456. <?xml version="1.0" encoding="UTF-8"?>
  457. <beans xmlns="http://www.springframework.org/schema/beans"
  458.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  459.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  460.     <bean id="vipBean" />
  461. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  462. <?xml version="1.0" encoding="UTF-8"?>
  463. <beans xmlns="http://www.springframework.org/schema/beans"
  464.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  465.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  466.     <bean id="vipBean" />
  467. </beans><bean id="userBean2" ></bean>
  468. <?xml version="1.0" encoding="UTF-8"?>
  469. <beans xmlns="http://www.springframework.org/schema/beans"
  470.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  471.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  472.     <bean id="vipBean" />
  473. </beans>
  474. </beans><?xml version="1.0" encoding="UTF-8"?>
  475. <beans xmlns="http://www.springframework.org/schema/beans"
  476.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  477.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  478.     <bean id="vipBean" />
  479. </beans>junit<?xml version="1.0" encoding="UTF-8"?>
  480. <beans xmlns="http://www.springframework.org/schema/beans"
  481. <?xml version="1.0" encoding="UTF-8"?>
  482. <beans xmlns="http://www.springframework.org/schema/beans"
  483.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  484.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  485.     <bean id="vipBean" />
  486. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  487. <?xml version="1.0" encoding="UTF-8"?>
  488. <beans xmlns="http://www.springframework.org/schema/beans"
  489.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  490.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  491.     <bean id="vipBean" />
  492. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  493. <?xml version="1.0" encoding="UTF-8"?>
  494. <beans xmlns="http://www.springframework.org/schema/beans"
  495.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  496.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  497.     <bean id="vipBean" />
  498. </beans><bean id="userBean2" ></bean>
  499. <?xml version="1.0" encoding="UTF-8"?>
  500. <beans xmlns="http://www.springframework.org/schema/beans"
  501.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  502.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  503.     <bean id="vipBean" />
  504. </beans>
  505. </beans><?xml version="1.0" encoding="UTF-8"?>
  506. <beans xmlns="http://www.springframework.org/schema/beans"
  507.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  508.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  509.     <bean id="vipBean" />
  510. </beans>4.13.2<?xml version="1.0" encoding="UTF-8"?>
  511. <beans xmlns="http://www.springframework.org/schema/beans"
  512. <?xml version="1.0" encoding="UTF-8"?>
  513. <beans xmlns="http://www.springframework.org/schema/beans"
  514.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  515.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  516.     <bean id="vipBean" />
  517. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  518. <?xml version="1.0" encoding="UTF-8"?>
  519. <beans xmlns="http://www.springframework.org/schema/beans"
  520.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  521.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  522.     <bean id="vipBean" />
  523. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  524. <?xml version="1.0" encoding="UTF-8"?>
  525. <beans xmlns="http://www.springframework.org/schema/beans"
  526.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  527.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  528.     <bean id="vipBean" />
  529. </beans><bean id="userBean2" ></bean>
  530. <?xml version="1.0" encoding="UTF-8"?>
  531. <beans xmlns="http://www.springframework.org/schema/beans"
  532.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  533.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  534.     <bean id="vipBean" />
  535. </beans>
  536. </beans><?xml version="1.0" encoding="UTF-8"?>
  537. <beans xmlns="http://www.springframework.org/schema/beans"
  538.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  539.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  540.     <bean id="vipBean" />
  541. </beans>test<?xml version="1.0" encoding="UTF-8"?>
  542. <beans xmlns="http://www.springframework.org/schema/beans"
  543. <?xml version="1.0" encoding="UTF-8"?>
  544. <beans xmlns="http://www.springframework.org/schema/beans"
  545.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  546.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  547.     <bean id="vipBean" />
  548. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  549. <?xml version="1.0" encoding="UTF-8"?>
  550. <beans xmlns="http://www.springframework.org/schema/beans"
  551.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  552.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  553.     <bean id="vipBean" />
  554. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  555. <?xml version="1.0" encoding="UTF-8"?>
  556. <beans xmlns="http://www.springframework.org/schema/beans"
  557.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  558.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  559.     <bean id="vipBean" />
  560. </beans><bean id="userBean2" ></bean>
  561. <?xml version="1.0" encoding="UTF-8"?>
  562. <beans xmlns="http://www.springframework.org/schema/beans"
  563.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  564.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  565.     <bean id="vipBean" />
  566. </beans>
  567. </beans><?xml version="1.0" encoding="UTF-8"?>
  568. <beans xmlns="http://www.springframework.org/schema/beans"
  569. <?xml version="1.0" encoding="UTF-8"?>
  570. <beans xmlns="http://www.springframework.org/schema/beans"
  571.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  572.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  573.     <bean id="vipBean" />
  574. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  575. <?xml version="1.0" encoding="UTF-8"?>
  576. <beans xmlns="http://www.springframework.org/schema/beans"
  577.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  578.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  579.     <bean id="vipBean" />
  580. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  581. <?xml version="1.0" encoding="UTF-8"?>
  582. <beans xmlns="http://www.springframework.org/schema/beans"
  583.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  584.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  585.     <bean id="vipBean" />
  586. </beans><bean id="userBean2" ></bean>
  587. <?xml version="1.0" encoding="UTF-8"?>
  588. <beans xmlns="http://www.springframework.org/schema/beans"
  589.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  590.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  591.     <bean id="vipBean" />
  592. </beans>
  593. </beans><?xml version="1.0" encoding="UTF-8"?>
  594. <beans xmlns="http://www.springframework.org/schema/beans"
  595. <?xml version="1.0" encoding="UTF-8"?>
  596. <beans xmlns="http://www.springframework.org/schema/beans"
  597.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  598.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  599.     <bean id="vipBean" />
  600. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  601. <?xml version="1.0" encoding="UTF-8"?>
  602. <beans xmlns="http://www.springframework.org/schema/beans"
  603.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  604.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  605.     <bean id="vipBean" />
  606. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  607. <?xml version="1.0" encoding="UTF-8"?>
  608. <beans xmlns="http://www.springframework.org/schema/beans"
  609.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  610.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  611.     <bean id="vipBean" />
  612. </beans><bean id="userBean2" ></bean>
  613. <?xml version="1.0" encoding="UTF-8"?>
  614. <beans xmlns="http://www.springframework.org/schema/beans"
  615.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  616.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  617.     <bean id="vipBean" />
  618. </beans>
  619. </beans><?xml version="1.0" encoding="UTF-8"?>
  620. <beans xmlns="http://www.springframework.org/schema/beans"
  621.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  622.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  623.     <bean id="vipBean" />
  624. </beans>org.apache.logging.log4j<?xml version="1.0" encoding="UTF-8"?>
  625. <beans xmlns="http://www.springframework.org/schema/beans"
  626. <?xml version="1.0" encoding="UTF-8"?>
  627. <beans xmlns="http://www.springframework.org/schema/beans"
  628.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  629.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  630.     <bean id="vipBean" />
  631. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  632. <?xml version="1.0" encoding="UTF-8"?>
  633. <beans xmlns="http://www.springframework.org/schema/beans"
  634.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  635.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  636.     <bean id="vipBean" />
  637. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  638. <?xml version="1.0" encoding="UTF-8"?>
  639. <beans xmlns="http://www.springframework.org/schema/beans"
  640.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  641.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  642.     <bean id="vipBean" />
  643. </beans><bean id="userBean2" ></bean>
  644. <?xml version="1.0" encoding="UTF-8"?>
  645. <beans xmlns="http://www.springframework.org/schema/beans"
  646.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  647.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  648.     <bean id="vipBean" />
  649. </beans>
  650. </beans><?xml version="1.0" encoding="UTF-8"?>
  651. <beans xmlns="http://www.springframework.org/schema/beans"
  652.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  653.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  654.     <bean id="vipBean" />
  655. </beans>log4j-core<?xml version="1.0" encoding="UTF-8"?>
  656. <beans xmlns="http://www.springframework.org/schema/beans"
  657. <?xml version="1.0" encoding="UTF-8"?>
  658. <beans xmlns="http://www.springframework.org/schema/beans"
  659.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  660.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  661.     <bean id="vipBean" />
  662. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  663. <?xml version="1.0" encoding="UTF-8"?>
  664. <beans xmlns="http://www.springframework.org/schema/beans"
  665.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  666.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  667.     <bean id="vipBean" />
  668. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  669. <?xml version="1.0" encoding="UTF-8"?>
  670. <beans xmlns="http://www.springframework.org/schema/beans"
  671.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  672.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  673.     <bean id="vipBean" />
  674. </beans><bean id="userBean2" ></bean>
  675. <?xml version="1.0" encoding="UTF-8"?>
  676. <beans xmlns="http://www.springframework.org/schema/beans"
  677.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  678.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  679.     <bean id="vipBean" />
  680. </beans>
  681. </beans><?xml version="1.0" encoding="UTF-8"?>
  682. <beans xmlns="http://www.springframework.org/schema/beans"
  683.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  684.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  685.     <bean id="vipBean" />
  686. </beans>2.19.0<?xml version="1.0" encoding="UTF-8"?>
  687. <beans xmlns="http://www.springframework.org/schema/beans"
  688. <?xml version="1.0" encoding="UTF-8"?>
  689. <beans xmlns="http://www.springframework.org/schema/beans"
  690.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  691.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  692.     <bean id="vipBean" />
  693. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  694. <?xml version="1.0" encoding="UTF-8"?>
  695. <beans xmlns="http://www.springframework.org/schema/beans"
  696.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  697.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  698.     <bean id="vipBean" />
  699. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  700. <?xml version="1.0" encoding="UTF-8"?>
  701. <beans xmlns="http://www.springframework.org/schema/beans"
  702.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  703.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  704.     <bean id="vipBean" />
  705. </beans><bean id="userBean2" ></bean>
  706. <?xml version="1.0" encoding="UTF-8"?>
  707. <beans xmlns="http://www.springframework.org/schema/beans"
  708.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  709.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  710.     <bean id="vipBean" />
  711. </beans>
  712. </beans><?xml version="1.0" encoding="UTF-8"?>
  713. <beans xmlns="http://www.springframework.org/schema/beans"
  714. <?xml version="1.0" encoding="UTF-8"?>
  715. <beans xmlns="http://www.springframework.org/schema/beans"
  716.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  717.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  718.     <bean id="vipBean" />
  719. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  720. <?xml version="1.0" encoding="UTF-8"?>
  721. <beans xmlns="http://www.springframework.org/schema/beans"
  722.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  723.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  724.     <bean id="vipBean" />
  725. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  726. <?xml version="1.0" encoding="UTF-8"?>
  727. <beans xmlns="http://www.springframework.org/schema/beans"
  728.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  729.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  730.     <bean id="vipBean" />
  731. </beans><bean id="userBean2" ></bean>
  732. <?xml version="1.0" encoding="UTF-8"?>
  733. <beans xmlns="http://www.springframework.org/schema/beans"
  734.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  735.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  736.     <bean id="vipBean" />
  737. </beans>
  738. </beans><?xml version="1.0" encoding="UTF-8"?>
  739. <beans xmlns="http://www.springframework.org/schema/beans"
  740. <?xml version="1.0" encoding="UTF-8"?>
  741. <beans xmlns="http://www.springframework.org/schema/beans"
  742.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  743.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  744.     <bean id="vipBean" />
  745. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  746. <?xml version="1.0" encoding="UTF-8"?>
  747. <beans xmlns="http://www.springframework.org/schema/beans"
  748.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  749.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  750.     <bean id="vipBean" />
  751. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  752. <?xml version="1.0" encoding="UTF-8"?>
  753. <beans xmlns="http://www.springframework.org/schema/beans"
  754.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  755.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  756.     <bean id="vipBean" />
  757. </beans><bean id="userBean2" ></bean>
  758. <?xml version="1.0" encoding="UTF-8"?>
  759. <beans xmlns="http://www.springframework.org/schema/beans"
  760.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  761.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  762.     <bean id="vipBean" />
  763. </beans>
  764. </beans><?xml version="1.0" encoding="UTF-8"?>
  765. <beans xmlns="http://www.springframework.org/schema/beans"
  766.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  767.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  768.     <bean id="vipBean" />
  769. </beans>org.apache.logging.log4j<?xml version="1.0" encoding="UTF-8"?>
  770. <beans xmlns="http://www.springframework.org/schema/beans"
  771. <?xml version="1.0" encoding="UTF-8"?>
  772. <beans xmlns="http://www.springframework.org/schema/beans"
  773.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  774.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  775.     <bean id="vipBean" />
  776. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  777. <?xml version="1.0" encoding="UTF-8"?>
  778. <beans xmlns="http://www.springframework.org/schema/beans"
  779.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  780.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  781.     <bean id="vipBean" />
  782. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  783. <?xml version="1.0" encoding="UTF-8"?>
  784. <beans xmlns="http://www.springframework.org/schema/beans"
  785.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  786.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  787.     <bean id="vipBean" />
  788. </beans><bean id="userBean2" ></bean>
  789. <?xml version="1.0" encoding="UTF-8"?>
  790. <beans xmlns="http://www.springframework.org/schema/beans"
  791.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  792.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  793.     <bean id="vipBean" />
  794. </beans>
  795. </beans><?xml version="1.0" encoding="UTF-8"?>
  796. <beans xmlns="http://www.springframework.org/schema/beans"
  797.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  798.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  799.     <bean id="vipBean" />
  800. </beans>log4j-slf4j2-impl<?xml version="1.0" encoding="UTF-8"?>
  801. <beans xmlns="http://www.springframework.org/schema/beans"
  802. <?xml version="1.0" encoding="UTF-8"?>
  803. <beans xmlns="http://www.springframework.org/schema/beans"
  804.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  805.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  806.     <bean id="vipBean" />
  807. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  808. <?xml version="1.0" encoding="UTF-8"?>
  809. <beans xmlns="http://www.springframework.org/schema/beans"
  810.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  811.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  812.     <bean id="vipBean" />
  813. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  814. <?xml version="1.0" encoding="UTF-8"?>
  815. <beans xmlns="http://www.springframework.org/schema/beans"
  816.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  817.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  818.     <bean id="vipBean" />
  819. </beans><bean id="userBean2" ></bean>
  820. <?xml version="1.0" encoding="UTF-8"?>
  821. <beans xmlns="http://www.springframework.org/schema/beans"
  822.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  823.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  824.     <bean id="vipBean" />
  825. </beans>
  826. </beans><?xml version="1.0" encoding="UTF-8"?>
  827. <beans xmlns="http://www.springframework.org/schema/beans"
  828.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  829.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  830.     <bean id="vipBean" />
  831. </beans>2.19.0<?xml version="1.0" encoding="UTF-8"?>
  832. <beans xmlns="http://www.springframework.org/schema/beans"
  833. <?xml version="1.0" encoding="UTF-8"?>
  834. <beans xmlns="http://www.springframework.org/schema/beans"
  835.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  836.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  837.     <bean id="vipBean" />
  838. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  839. <?xml version="1.0" encoding="UTF-8"?>
  840. <beans xmlns="http://www.springframework.org/schema/beans"
  841.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  842.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  843.     <bean id="vipBean" />
  844. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  845. <?xml version="1.0" encoding="UTF-8"?>
  846. <beans xmlns="http://www.springframework.org/schema/beans"
  847.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  848.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  849.     <bean id="vipBean" />
  850. </beans><bean id="userBean2" ></bean>
  851. <?xml version="1.0" encoding="UTF-8"?>
  852. <beans xmlns="http://www.springframework.org/schema/beans"
  853.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  854.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  855.     <bean id="vipBean" />
  856. </beans>
  857. </beans><?xml version="1.0" encoding="UTF-8"?>
  858. <beans xmlns="http://www.springframework.org/schema/beans"
  859.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  860.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  861.     <bean id="vipBean" />
  862. </beans>
复制代码
注意:打包方式jar。
当加入spring context的依赖之后,会关联引入其他依赖:
spring aop:面向切面编程
spring beans:IoC核心
spring core:spring的核心工具包
spring jcl:spring的日志包
spring expression:spring表达式

第三步: bean : User
在:Spring 框架中,每一个管理的类,都是 bean ,在 xml 中基本上面向 bean 编写的。
  1. package com.rainbowsea.spring6.bean;
  2. /**
  3. * 这是一个bean ,封装了用户的信息,Spring 可以帮助我们创建User对象吗?
  4. *
  5. */
  6. public class User {
  7. <?xml version="1.0" encoding="UTF-8"?>
  8. <beans xmlns="http://www.springframework.org/schema/beans"
  9.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  11.     <bean id="vipBean" />
  12. </beans>// Spring 是怎么实例化对象的?
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>// 默认情况下Spring 是通过反射机制,调用类的无参数构造方法来实例化对象的
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>// 所以,对于反射来说,我们来要有,一定要有私有的构造器
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans>// Class<?> clazz = Class.forName("com.rainbowsea.spring6.bean.User");
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>//<?xml version="1.0" encoding="UTF-8"?>
  37. <beans xmlns="http://www.springframework.org/schema/beans"
  38. <?xml version="1.0" encoding="UTF-8"?>
  39. <beans xmlns="http://www.springframework.org/schema/beans"
  40.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  41.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  42.     <bean id="vipBean" />
  43. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44. <?xml version="1.0" encoding="UTF-8"?>
  45. <beans xmlns="http://www.springframework.org/schema/beans"
  46.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  47.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  48.     <bean id="vipBean" />
  49. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  50. <?xml version="1.0" encoding="UTF-8"?>
  51. <beans xmlns="http://www.springframework.org/schema/beans"
  52.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  53.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  54.     <bean id="vipBean" />
  55. </beans><bean id="userBean2" ></bean>
  56. <?xml version="1.0" encoding="UTF-8"?>
  57. <beans xmlns="http://www.springframework.org/schema/beans"
  58.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  59.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  60.     <bean id="vipBean" />
  61. </beans>
  62. </beans>Object o = clazz.newInstance();
  63. <?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  66.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  67.     <bean id="vipBean" />
  68. </beans>public User () {
  69. <?xml version="1.0" encoding="UTF-8"?>
  70. <beans xmlns="http://www.springframework.org/schema/beans"
  71. <?xml version="1.0" encoding="UTF-8"?>
  72. <beans xmlns="http://www.springframework.org/schema/beans"
  73.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  74.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  75.     <bean id="vipBean" />
  76. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  77. <?xml version="1.0" encoding="UTF-8"?>
  78. <beans xmlns="http://www.springframework.org/schema/beans"
  79.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  80.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  81.     <bean id="vipBean" />
  82. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  87.     <bean id="vipBean" />
  88. </beans><bean id="userBean2" ></bean>
  89. <?xml version="1.0" encoding="UTF-8"?>
  90. <beans xmlns="http://www.springframework.org/schema/beans"
  91.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  92.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  93.     <bean id="vipBean" />
  94. </beans>
  95. </beans>System.out.println("User 的无参数构造器构造方法的执行");
  96. <?xml version="1.0" encoding="UTF-8"?>
  97. <beans xmlns="http://www.springframework.org/schema/beans"
  98.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  99.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  100.     <bean id="vipBean" />
  101. </beans>}
  102. }
复制代码
第四步:编写spring的配置文件:beans.xml。该文件放在类的根路径下。


上图是使用IDEA工具自带的spring配置文件的模板进行创建
  1. [/code]对 Spring 配置文件中进行 bean 的配置:
  2. **注意: **
  3. [list]
  4. [*][b]id属性:代表对象的唯一标识。可以看做一个人的身份证号。[/b]
  5. [*][b]class属性:用来指定要创建的java对象的类名,这个类名必须是全限定类名(带包名)。[/b]
  6. [/list][code]<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <beans xmlns="http://www.springframework.org/schema/beans"
  10.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  12.     <bean id="vipBean" />
  13. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14. <?xml version="1.0" encoding="UTF-8"?>
  15. <beans xmlns="http://www.springframework.org/schema/beans"
  16.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  18.     <bean id="vipBean" />
  19. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20. <?xml version="1.0" encoding="UTF-8"?>
  21. <beans xmlns="http://www.springframework.org/schema/beans"
  22.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  23.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  24.     <bean id="vipBean" />
  25. </beans><bean id="userBean2" ></bean>
  26. <?xml version="1.0" encoding="UTF-8"?>
  27. <beans xmlns="http://www.springframework.org/schema/beans"
  28.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  29.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  30.     <bean id="vipBean" />
  31. </beans>
  32. </beans>
复制代码
第五步:编写测试程序
这里我们使用: JUit4 的测试:
  1. package com.rainbowsea.spring6;import com.rainbowsea.spring6.bean.User;import com.rainbowsea.spring6.bean.UserDao;import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import org.springframework.context.support.FileSystemXmlApplicationContext;import java.text.SimpleDateFormat;import java.util.Date;public class FirstSpringTest {<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>@Test<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  10.     <bean id="vipBean" />
  11. </beans>public void testFirstSpringCode() {<?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans><bean id="userBean2" ></bean>
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>
  37. </beans>// 第一步:获取到Spring 容器对象<?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <beans xmlns="http://www.springframework.org/schema/beans"
  41.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  42.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43.     <bean id="vipBean" />
  44. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <beans xmlns="http://www.springframework.org/schema/beans"
  47.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  49.     <bean id="vipBean" />
  50. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  51. <?xml version="1.0" encoding="UTF-8"?>
  52. <beans xmlns="http://www.springframework.org/schema/beans"
  53.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  55.     <bean id="vipBean" />
  56. </beans><bean id="userBean2" ></bean>
  57. <?xml version="1.0" encoding="UTF-8"?>
  58. <beans xmlns="http://www.springframework.org/schema/beans"
  59.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61.     <bean id="vipBean" />
  62. </beans>
  63. </beans>// ApplicationContext 翻译为: 应用上下文,其实就是<?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65. <?xml version="1.0" encoding="UTF-8"?>
  66. <beans xmlns="http://www.springframework.org/schema/beans"
  67.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  68.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  69.     <bean id="vipBean" />
  70. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  71. <?xml version="1.0" encoding="UTF-8"?>
  72. <beans xmlns="http://www.springframework.org/schema/beans"
  73.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  74.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  75.     <bean id="vipBean" />
  76. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77. <?xml version="1.0" encoding="UTF-8"?>
  78. <beans xmlns="http://www.springframework.org/schema/beans"
  79.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  80.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  81.     <bean id="vipBean" />
  82. </beans><bean id="userBean2" ></bean>
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  87.     <bean id="vipBean" />
  88. </beans>
  89. </beans>// ApplicationContext 是一个接口:<?xml version="1.0" encoding="UTF-8"?>
  90. <beans xmlns="http://www.springframework.org/schema/beans"
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <beans xmlns="http://www.springframework.org/schema/beans"
  99.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  101.     <bean id="vipBean" />
  102. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  107.     <bean id="vipBean" />
  108. </beans><bean id="userBean2" ></bean>
  109. <?xml version="1.0" encoding="UTF-8"?>
  110. <beans xmlns="http://www.springframework.org/schema/beans"
  111.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  113.     <bean id="vipBean" />
  114. </beans>
  115. </beans>// ApplicationContest 接口下有很多实现类,其中有一个实现类叫做:ClassPathXmlApplicationContext<?xml version="1.0" encoding="UTF-8"?>
  116. <beans xmlns="http://www.springframework.org/schema/beans"
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><bean id="userBean2" ></bean>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139.     <bean id="vipBean" />
  140. </beans>
  141. </beans>// ClassPathXmlApplicationContext 专门从类路径当中加载Spring 配置文件的一个类<?xml version="1.0" encoding="UTF-8"?>
  142. <beans xmlns="http://www.springframework.org/schema/beans"
  143. <?xml version="1.0" encoding="UTF-8"?>
  144. <beans xmlns="http://www.springframework.org/schema/beans"
  145.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  146.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  147.     <bean id="vipBean" />
  148. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans><bean id="userBean2" ></bean>
  161. <?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans>
  167. </beans>// 下面这行代码只要执行,就相当与启动了/Spring 容器,解析Spring.xml 文件.<?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169. <?xml version="1.0" encoding="UTF-8"?>
  170. <beans xmlns="http://www.springframework.org/schema/beans"
  171.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  172.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  173.     <bean id="vipBean" />
  174. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  175. <?xml version="1.0" encoding="UTF-8"?>
  176. <beans xmlns="http://www.springframework.org/schema/beans"
  177.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  178.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  179.     <bean id="vipBean" />
  180. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans><bean id="userBean2" ></bean>
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>
  193. </beans>// 面向接口编程,左边的是接口,右边的类<?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195. <?xml version="1.0" encoding="UTF-8"?>
  196. <beans xmlns="http://www.springframework.org/schema/beans"
  197.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  198.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  199.     <bean id="vipBean" />
  200. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  201. <?xml version="1.0" encoding="UTF-8"?>
  202. <beans xmlns="http://www.springframework.org/schema/beans"
  203.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  204.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  205.     <bean id="vipBean" />
  206. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  207. <?xml version="1.0" encoding="UTF-8"?>
  208. <beans xmlns="http://www.springframework.org/schema/beans"
  209.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  210.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  211.     <bean id="vipBean" />
  212. </beans><bean id="userBean2" ></bean>
  213. <?xml version="1.0" encoding="UTF-8"?>
  214. <beans xmlns="http://www.springframework.org/schema/beans"
  215.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  216.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  217.     <bean id="vipBean" />
  218. </beans>
  219. </beans> ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");<?xml version="1.0" encoding="UTF-8"?>
  220. <beans xmlns="http://www.springframework.org/schema/beans"
  221. <?xml version="1.0" encoding="UTF-8"?>
  222. <beans xmlns="http://www.springframework.org/schema/beans"
  223.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  224.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  225.     <bean id="vipBean" />
  226. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  227. <?xml version="1.0" encoding="UTF-8"?>
  228. <beans xmlns="http://www.springframework.org/schema/beans"
  229.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  230.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  231.     <bean id="vipBean" />
  232. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  233. <?xml version="1.0" encoding="UTF-8"?>
  234. <beans xmlns="http://www.springframework.org/schema/beans"
  235.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  236.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  237.     <bean id="vipBean" />
  238. </beans><bean id="userBean2" ></bean>
  239. <?xml version="1.0" encoding="UTF-8"?>
  240. <beans xmlns="http://www.springframework.org/schema/beans"
  241.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  242.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  243.     <bean id="vipBean" />
  244. </beans>
  245. </beans>/**<?xml version="1.0" encoding="UTF-8"?>
  246. <beans xmlns="http://www.springframework.org/schema/beans"
  247. <?xml version="1.0" encoding="UTF-8"?>
  248. <beans xmlns="http://www.springframework.org/schema/beans"
  249.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  250.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  251.     <bean id="vipBean" />
  252. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  253. <?xml version="1.0" encoding="UTF-8"?>
  254. <beans xmlns="http://www.springframework.org/schema/beans"
  255.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  256.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  257.     <bean id="vipBean" />
  258. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  259. <?xml version="1.0" encoding="UTF-8"?>
  260. <beans xmlns="http://www.springframework.org/schema/beans"
  261.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  262.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  263.     <bean id="vipBean" />
  264. </beans><bean id="userBean2" ></bean>
  265. <?xml version="1.0" encoding="UTF-8"?>
  266. <beans xmlns="http://www.springframework.org/schema/beans"
  267.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  268.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  269.     <bean id="vipBean" />
  270. </beans>
  271. </beans> * 源码分析:<?xml version="1.0" encoding="UTF-8"?>
  272. <beans xmlns="http://www.springframework.org/schema/beans"
  273. <?xml version="1.0" encoding="UTF-8"?>
  274. <beans xmlns="http://www.springframework.org/schema/beans"
  275.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  276.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  277.     <bean id="vipBean" />
  278. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  279. <?xml version="1.0" encoding="UTF-8"?>
  280. <beans xmlns="http://www.springframework.org/schema/beans"
  281.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  282.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  283.     <bean id="vipBean" />
  284. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  285. <?xml version="1.0" encoding="UTF-8"?>
  286. <beans xmlns="http://www.springframework.org/schema/beans"
  287.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  288.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  289.     <bean id="vipBean" />
  290. </beans><bean id="userBean2" ></bean>
  291. <?xml version="1.0" encoding="UTF-8"?>
  292. <beans xmlns="http://www.springframework.org/schema/beans"
  293.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  294.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  295.     <bean id="vipBean" />
  296. </beans>
  297. </beans> *<?xml version="1.0" encoding="UTF-8"?>
  298. <beans xmlns="http://www.springframework.org/schema/beans"
  299.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  300.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  301.     <bean id="vipBean" />
  302. </beans> public ClassPathXmlApplicationContext(String... configLocations) throws BeansException {<?xml version="1.0" encoding="UTF-8"?>
  303. <beans xmlns="http://www.springframework.org/schema/beans"
  304. <?xml version="1.0" encoding="UTF-8"?>
  305. <beans xmlns="http://www.springframework.org/schema/beans"
  306.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  307.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  308.     <bean id="vipBean" />
  309. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  310. <?xml version="1.0" encoding="UTF-8"?>
  311. <beans xmlns="http://www.springframework.org/schema/beans"
  312.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  313.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  314.     <bean id="vipBean" />
  315. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  316. <?xml version="1.0" encoding="UTF-8"?>
  317. <beans xmlns="http://www.springframework.org/schema/beans"
  318.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  319.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  320.     <bean id="vipBean" />
  321. </beans><bean id="userBean2" ></bean>
  322. <?xml version="1.0" encoding="UTF-8"?>
  323. <beans xmlns="http://www.springframework.org/schema/beans"
  324.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  325.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  326.     <bean id="vipBean" />
  327. </beans>
  328. </beans> *<?xml version="1.0" encoding="UTF-8"?>
  329. <beans xmlns="http://www.springframework.org/schema/beans"
  330. <?xml version="1.0" encoding="UTF-8"?>
  331. <beans xmlns="http://www.springframework.org/schema/beans"
  332.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  333.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  334.     <bean id="vipBean" />
  335. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  336. <?xml version="1.0" encoding="UTF-8"?>
  337. <beans xmlns="http://www.springframework.org/schema/beans"
  338.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  339.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  340.     <bean id="vipBean" />
  341. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  342. <?xml version="1.0" encoding="UTF-8"?>
  343. <beans xmlns="http://www.springframework.org/schema/beans"
  344.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  345.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  346.     <bean id="vipBean" />
  347. </beans><bean id="userBean2" ></bean>
  348. <?xml version="1.0" encoding="UTF-8"?>
  349. <beans xmlns="http://www.springframework.org/schema/beans"
  350.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  351.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  352.     <bean id="vipBean" />
  353. </beans>
  354. </beans> this(configLocations, true, (ApplicationContext)null);<?xml version="1.0" encoding="UTF-8"?>
  355. <beans xmlns="http://www.springframework.org/schema/beans"
  356. <?xml version="1.0" encoding="UTF-8"?>
  357. <beans xmlns="http://www.springframework.org/schema/beans"
  358.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  359.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  360.     <bean id="vipBean" />
  361. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  362. <?xml version="1.0" encoding="UTF-8"?>
  363. <beans xmlns="http://www.springframework.org/schema/beans"
  364.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  365.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  366.     <bean id="vipBean" />
  367. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  368. <?xml version="1.0" encoding="UTF-8"?>
  369. <beans xmlns="http://www.springframework.org/schema/beans"
  370.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  371.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  372.     <bean id="vipBean" />
  373. </beans><bean id="userBean2" ></bean>
  374. <?xml version="1.0" encoding="UTF-8"?>
  375. <beans xmlns="http://www.springframework.org/schema/beans"
  376.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  377.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  378.     <bean id="vipBean" />
  379. </beans>
  380. </beans> *<?xml version="1.0" encoding="UTF-8"?>
  381. <beans xmlns="http://www.springframework.org/schema/beans"
  382.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  383.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  384.     <bean id="vipBean" />
  385. </beans> }<?xml version="1.0" encoding="UTF-8"?>
  386. <beans xmlns="http://www.springframework.org/schema/beans"
  387. <?xml version="1.0" encoding="UTF-8"?>
  388. <beans xmlns="http://www.springframework.org/schema/beans"
  389.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  390.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  391.     <bean id="vipBean" />
  392. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  393. <?xml version="1.0" encoding="UTF-8"?>
  394. <beans xmlns="http://www.springframework.org/schema/beans"
  395.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  396.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  397.     <bean id="vipBean" />
  398. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  399. <?xml version="1.0" encoding="UTF-8"?>
  400. <beans xmlns="http://www.springframework.org/schema/beans"
  401.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  402.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  403.     <bean id="vipBean" />
  404. </beans><bean id="userBean2" ></bean>
  405. <?xml version="1.0" encoding="UTF-8"?>
  406. <beans xmlns="http://www.springframework.org/schema/beans"
  407.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  408.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  409.     <bean id="vipBean" />
  410. </beans>
  411. </beans> *<?xml version="1.0" encoding="UTF-8"?>
  412. <beans xmlns="http://www.springframework.org/schema/beans"
  413.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  414.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  415.     <bean id="vipBean" />
  416. </beans> 可变参数,说明可以传入多个参数西信息;<?xml version="1.0" encoding="UTF-8"?>
  417. <beans xmlns="http://www.springframework.org/schema/beans"
  418. <?xml version="1.0" encoding="UTF-8"?>
  419. <beans xmlns="http://www.springframework.org/schema/beans"
  420.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  421.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  422.     <bean id="vipBean" />
  423. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  424. <?xml version="1.0" encoding="UTF-8"?>
  425. <beans xmlns="http://www.springframework.org/schema/beans"
  426.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  427.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  428.     <bean id="vipBean" />
  429. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  430. <?xml version="1.0" encoding="UTF-8"?>
  431. <beans xmlns="http://www.springframework.org/schema/beans"
  432.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  433.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  434.     <bean id="vipBean" />
  435. </beans><bean id="userBean2" ></bean>
  436. <?xml version="1.0" encoding="UTF-8"?>
  437. <beans xmlns="http://www.springframework.org/schema/beans"
  438.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  439.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  440.     <bean id="vipBean" />
  441. </beans>
  442. </beans> *<?xml version="1.0" encoding="UTF-8"?>
  443. <beans xmlns="http://www.springframework.org/schema/beans"
  444. <?xml version="1.0" encoding="UTF-8"?>
  445. <beans xmlns="http://www.springframework.org/schema/beans"
  446.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  447.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  448.     <bean id="vipBean" />
  449. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  450. <?xml version="1.0" encoding="UTF-8"?>
  451. <beans xmlns="http://www.springframework.org/schema/beans"
  452.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  453.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  454.     <bean id="vipBean" />
  455. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  456. <?xml version="1.0" encoding="UTF-8"?>
  457. <beans xmlns="http://www.springframework.org/schema/beans"
  458.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  459.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  460.     <bean id="vipBean" />
  461. </beans><bean id="userBean2" ></bean>
  462. <?xml version="1.0" encoding="UTF-8"?>
  463. <beans xmlns="http://www.springframework.org/schema/beans"
  464.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  465.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  466.     <bean id="vipBean" />
  467. </beans>
  468. </beans> */<?xml version="1.0" encoding="UTF-8"?>
  469. <beans xmlns="http://www.springframework.org/schema/beans"
  470. <?xml version="1.0" encoding="UTF-8"?>
  471. <beans xmlns="http://www.springframework.org/schema/beans"
  472.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  473.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  474.     <bean id="vipBean" />
  475. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  476. <?xml version="1.0" encoding="UTF-8"?>
  477. <beans xmlns="http://www.springframework.org/schema/beans"
  478.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  479.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  480.     <bean id="vipBean" />
  481. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  482. <?xml version="1.0" encoding="UTF-8"?>
  483. <beans xmlns="http://www.springframework.org/schema/beans"
  484.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  485.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  486.     <bean id="vipBean" />
  487. </beans><bean id="userBean2" ></bean>
  488. <?xml version="1.0" encoding="UTF-8"?>
  489. <beans xmlns="http://www.springframework.org/schema/beans"
  490.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  491.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  492.     <bean id="vipBean" />
  493. </beans>
  494. </beans>// 第二步: 根据bean 的id从Spring 的容器中获取到这个对象<?xml version="1.0" encoding="UTF-8"?>
  495. <beans xmlns="http://www.springframework.org/schema/beans"
  496. <?xml version="1.0" encoding="UTF-8"?>
  497. <beans xmlns="http://www.springframework.org/schema/beans"
  498.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  499.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  500.     <bean id="vipBean" />
  501. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  502. <?xml version="1.0" encoding="UTF-8"?>
  503. <beans xmlns="http://www.springframework.org/schema/beans"
  504.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  505.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  506.     <bean id="vipBean" />
  507. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  508. <?xml version="1.0" encoding="UTF-8"?>
  509. <beans xmlns="http://www.springframework.org/schema/beans"
  510.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  511.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  512.     <bean id="vipBean" />
  513. </beans><bean id="userBean2" ></bean>
  514. <?xml version="1.0" encoding="UTF-8"?>
  515. <beans xmlns="http://www.springframework.org/schema/beans"
  516.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  517.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  518.     <bean id="vipBean" />
  519. </beans>
  520. </beans>// 注意:这个name ,尽量使用 copy 的方式,防止发生错误<?xml version="1.0" encoding="UTF-8"?>
  521. <beans xmlns="http://www.springframework.org/schema/beans"
  522. <?xml version="1.0" encoding="UTF-8"?>
  523. <beans xmlns="http://www.springframework.org/schema/beans"
  524.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  525.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  526.     <bean id="vipBean" />
  527. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  528. <?xml version="1.0" encoding="UTF-8"?>
  529. <beans xmlns="http://www.springframework.org/schema/beans"
  530.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  531.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  532.     <bean id="vipBean" />
  533. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  534. <?xml version="1.0" encoding="UTF-8"?>
  535. <beans xmlns="http://www.springframework.org/schema/beans"
  536.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  537.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  538.     <bean id="vipBean" />
  539. </beans><bean id="userBean2" ></bean>
  540. <?xml version="1.0" encoding="UTF-8"?>
  541. <beans xmlns="http://www.springframework.org/schema/beans"
  542.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  543.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  544.     <bean id="vipBean" />
  545. </beans>
  546. </beans>Object userBean = applicationContext.getBean("userBean");<?xml version="1.0" encoding="UTF-8"?>
  547. <beans xmlns="http://www.springframework.org/schema/beans"
  548. <?xml version="1.0" encoding="UTF-8"?>
  549. <beans xmlns="http://www.springframework.org/schema/beans"
  550.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  551.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  552.     <bean id="vipBean" />
  553. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  554. <?xml version="1.0" encoding="UTF-8"?>
  555. <beans xmlns="http://www.springframework.org/schema/beans"
  556.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  557.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  558.     <bean id="vipBean" />
  559. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  560. <?xml version="1.0" encoding="UTF-8"?>
  561. <beans xmlns="http://www.springframework.org/schema/beans"
  562.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  563.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  564.     <bean id="vipBean" />
  565. </beans><bean id="userBean2" ></bean>
  566. <?xml version="1.0" encoding="UTF-8"?>
  567. <beans xmlns="http://www.springframework.org/schema/beans"
  568.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  569.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  570.     <bean id="vipBean" />
  571. </beans>
  572. </beans>System.out.println(userBean);<?xml version="1.0" encoding="UTF-8"?>
  573. <beans xmlns="http://www.springframework.org/schema/beans"
  574.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  575.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  576.     <bean id="vipBean" />
  577. </beans>}}
复制代码

4. 第一个Spring程序详细剖析
  1. [/code][code]ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
  2. Object userBean = applicationContext.getBean("userBean");
复制代码
4.1  bean标签的id属性可以重复吗?

注意: 在 Spring 当中的 xml 中对应配置的  bean 中的 id属性的值是不可以重复的,它就像人的身份证号一样的,不可重复。
  1. package com.powernode.spring6.bean;public class Vip {}<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  7.     <bean id="vipBean" />
  8. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. <?xml version="1.0" encoding="UTF-8"?>
  10. <beans xmlns="http://www.springframework.org/schema/beans"
  11.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  12.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  13.     <bean id="vipBean" />
  14. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15. <?xml version="1.0" encoding="UTF-8"?>
  16. <beans xmlns="http://www.springframework.org/schema/beans"
  17.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  18.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  19.     <bean id="vipBean" />
  20. </beans><bean id="userBean2" ></bean>
  21. <?xml version="1.0" encoding="UTF-8"?>
  22. <beans xmlns="http://www.springframework.org/schema/beans"
  23.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25.     <bean id="vipBean" />
  26. </beans>
  27. </beans><?xml version="1.0" encoding="UTF-8"?>
  28. <beans xmlns="http://www.springframework.org/schema/beans"
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  32.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  33.     <bean id="vipBean" />
  34. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <beans xmlns="http://www.springframework.org/schema/beans"
  37.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  39.     <bean id="vipBean" />
  40. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41. <?xml version="1.0" encoding="UTF-8"?>
  42. <beans xmlns="http://www.springframework.org/schema/beans"
  43.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  45.     <bean id="vipBean" />
  46. </beans><bean id="userBean2" ></bean>
  47. <?xml version="1.0" encoding="UTF-8"?>
  48. <beans xmlns="http://www.springframework.org/schema/beans"
  49.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  50.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  51.     <bean id="vipBean" />
  52. </beans>
  53. </beans>
复制代码
运行测试程序:

通过测试得出:在spring的配置文件中id是不能重名。
4.2 底层是怎么创建对象的,是通过反射机制调用无参数构造方法吗?
  1. package com.powernode.spring6.bean;public class User {<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>public User() {<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <beans xmlns="http://www.springframework.org/schema/beans"
  10.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  12.     <bean id="vipBean" />
  13. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14. <?xml version="1.0" encoding="UTF-8"?>
  15. <beans xmlns="http://www.springframework.org/schema/beans"
  16.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  18.     <bean id="vipBean" />
  19. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20. <?xml version="1.0" encoding="UTF-8"?>
  21. <beans xmlns="http://www.springframework.org/schema/beans"
  22.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  23.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  24.     <bean id="vipBean" />
  25. </beans><bean id="userBean2" ></bean>
  26. <?xml version="1.0" encoding="UTF-8"?>
  27. <beans xmlns="http://www.springframework.org/schema/beans"
  28.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  29.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  30.     <bean id="vipBean" />
  31. </beans>
  32. </beans>System.out.println("User的无参数构造方法执行");<?xml version="1.0" encoding="UTF-8"?>
  33. <beans xmlns="http://www.springframework.org/schema/beans"
  34.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  35.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  36.     <bean id="vipBean" />
  37. </beans>}}
复制代码
在User类中添加无参数构造方法,如上。
运行测试程序:

通过测试得知:创建对象时确实调用了无参数构造方法。
如果提供一个有参数构造方法,不提供无参数构造方法会怎样呢?
  1. package com.powernode.spring6.bean;public class User {<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>/*public User() {<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <beans xmlns="http://www.springframework.org/schema/beans"
  10.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  12.     <bean id="vipBean" />
  13. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  14. <?xml version="1.0" encoding="UTF-8"?>
  15. <beans xmlns="http://www.springframework.org/schema/beans"
  16.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  18.     <bean id="vipBean" />
  19. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20. <?xml version="1.0" encoding="UTF-8"?>
  21. <beans xmlns="http://www.springframework.org/schema/beans"
  22.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  23.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  24.     <bean id="vipBean" />
  25. </beans><bean id="userBean2" ></bean>
  26. <?xml version="1.0" encoding="UTF-8"?>
  27. <beans xmlns="http://www.springframework.org/schema/beans"
  28.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  29.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  30.     <bean id="vipBean" />
  31. </beans>
  32. </beans>System.out.println("User的无参数构造方法执行");<?xml version="1.0" encoding="UTF-8"?>
  33. <beans xmlns="http://www.springframework.org/schema/beans"
  34.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  35.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  36.     <bean id="vipBean" />
  37. </beans>}*/<?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41.     <bean id="vipBean" />
  42. </beans>public User(String name){<?xml version="1.0" encoding="UTF-8"?>
  43. <beans xmlns="http://www.springframework.org/schema/beans"
  44. <?xml version="1.0" encoding="UTF-8"?>
  45. <beans xmlns="http://www.springframework.org/schema/beans"
  46.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  47.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  48.     <bean id="vipBean" />
  49. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  50. <?xml version="1.0" encoding="UTF-8"?>
  51. <beans xmlns="http://www.springframework.org/schema/beans"
  52.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  53.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  54.     <bean id="vipBean" />
  55. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  56. <?xml version="1.0" encoding="UTF-8"?>
  57. <beans xmlns="http://www.springframework.org/schema/beans"
  58.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  59.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  60.     <bean id="vipBean" />
  61. </beans><bean id="userBean2" ></bean>
  62. <?xml version="1.0" encoding="UTF-8"?>
  63. <beans xmlns="http://www.springframework.org/schema/beans"
  64.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  65.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  66.     <bean id="vipBean" />
  67. </beans>
  68. </beans>System.out.println("User的有参数构造方法执行");<?xml version="1.0" encoding="UTF-8"?>
  69. <beans xmlns="http://www.springframework.org/schema/beans"
  70.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  71.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  72.     <bean id="vipBean" />
  73. </beans>}}
复制代码
运行测试程序:

通过测试得知:spring是通过调用类的无参数构造方法来创建对象的,所以要想让spring给你创建对象,必须保证无参数构造方法是存在的。
Spring是如何创建对象的呢?原理是什么?
  1. // dom4j解析beans.xml文件,从中获取class的全限定类名
  2. // 通过反射机制调用无参数构造方法创建对象
  3. Class clazz = Class.forName("com.powernode.spring6.bean.User");
  4. Object obj = clazz.newInstance();
复制代码
4.3 把创建好的对象存储到一个什么样的数据结构当中了呢?


4.4  spring配置文件的名字必须叫做beans.xml吗?
  1. ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
复制代码
通过以上的java代码可以看出,这个spring配置文件名字是我们负责提供的,显然spring配置文件的名字是随意的。
再创建一个spring配置文件,起名:spring.xml
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>
复制代码
  1. package com.powernode.spring6.test;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class Spring6Test {<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>@Test<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  10.     <bean id="vipBean" />
  11. </beans>public void testFirst(){<?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans><bean id="userBean2" ></bean>
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>
  37. </beans>// 初始化Spring容器上下文(解析beans.xml文件,创建所有的bean对象)<?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <beans xmlns="http://www.springframework.org/schema/beans"
  41.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  42.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43.     <bean id="vipBean" />
  44. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <beans xmlns="http://www.springframework.org/schema/beans"
  47.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  49.     <bean id="vipBean" />
  50. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  51. <?xml version="1.0" encoding="UTF-8"?>
  52. <beans xmlns="http://www.springframework.org/schema/beans"
  53.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  55.     <bean id="vipBean" />
  56. </beans><bean id="userBean2" ></bean>
  57. <?xml version="1.0" encoding="UTF-8"?>
  58. <beans xmlns="http://www.springframework.org/schema/beans"
  59.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61.     <bean id="vipBean" />
  62. </beans>
  63. </beans>ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml","spring.xml");<?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65. <?xml version="1.0" encoding="UTF-8"?>
  66. <beans xmlns="http://www.springframework.org/schema/beans"
  67.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  68.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  69.     <bean id="vipBean" />
  70. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  71. <?xml version="1.0" encoding="UTF-8"?>
  72. <beans xmlns="http://www.springframework.org/schema/beans"
  73.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  74.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  75.     <bean id="vipBean" />
  76. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77. <?xml version="1.0" encoding="UTF-8"?>
  78. <beans xmlns="http://www.springframework.org/schema/beans"
  79.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  80.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  81.     <bean id="vipBean" />
  82. </beans><bean id="userBean2" ></bean>
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  87.     <bean id="vipBean" />
  88. </beans>
  89. </beans>// 根据id获取bean对象<?xml version="1.0" encoding="UTF-8"?>
  90. <beans xmlns="http://www.springframework.org/schema/beans"
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <beans xmlns="http://www.springframework.org/schema/beans"
  99.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  101.     <bean id="vipBean" />
  102. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  107.     <bean id="vipBean" />
  108. </beans><bean id="userBean2" ></bean>
  109. <?xml version="1.0" encoding="UTF-8"?>
  110. <beans xmlns="http://www.springframework.org/schema/beans"
  111.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  113.     <bean id="vipBean" />
  114. </beans>
  115. </beans>Object userBean = applicationContext.getBean("userBean");<?xml version="1.0" encoding="UTF-8"?>
  116. <beans xmlns="http://www.springframework.org/schema/beans"
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><bean id="userBean2" ></bean>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139.     <bean id="vipBean" />
  140. </beans>
  141. </beans>Object vipBean = applicationContext.getBean("vipBean");<?xml version="1.0" encoding="UTF-8"?>
  142. <beans xmlns="http://www.springframework.org/schema/beans"
  143. <?xml version="1.0" encoding="UTF-8"?>
  144. <beans xmlns="http://www.springframework.org/schema/beans"
  145.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  146.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  147.     <bean id="vipBean" />
  148. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans><bean id="userBean2" ></bean>
  161. <?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans>
  167. </beans>System.out.println(userBean);<?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169. <?xml version="1.0" encoding="UTF-8"?>
  170. <beans xmlns="http://www.springframework.org/schema/beans"
  171.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  172.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  173.     <bean id="vipBean" />
  174. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  175. <?xml version="1.0" encoding="UTF-8"?>
  176. <beans xmlns="http://www.springframework.org/schema/beans"
  177.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  178.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  179.     <bean id="vipBean" />
  180. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans><bean id="userBean2" ></bean>
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>
  193. </beans>System.out.println(vipBean);<?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  196.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  197.     <bean id="vipBean" />
  198. </beans>}}
复制代码
运行测试程序:

通过测试得知,spring的配置文件可以有多个,在ClassPathXmlApplicationContext构造方法的参数上传递文件路径即可。这是为什么呢?通过源码可以看到:

4.5 在配置文件中配置的类必须是自定义的吗,可以使用JDK中的类吗,例如:java.util.Date?
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  7.     <bean id="vipBean" />
  8. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. <?xml version="1.0" encoding="UTF-8"?>
  10. <beans xmlns="http://www.springframework.org/schema/beans"
  11.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  12.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  13.     <bean id="vipBean" />
  14. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15. <?xml version="1.0" encoding="UTF-8"?>
  16. <beans xmlns="http://www.springframework.org/schema/beans"
  17.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  18.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  19.     <bean id="vipBean" />
  20. </beans><bean id="userBean2" ></bean>
  21. <?xml version="1.0" encoding="UTF-8"?>
  22. <beans xmlns="http://www.springframework.org/schema/beans"
  23.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25.     <bean id="vipBean" />
  26. </beans>
  27. </beans><?xml version="1.0" encoding="UTF-8"?>
  28. <beans xmlns="http://www.springframework.org/schema/beans"
  29.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  30.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  31.     <bean id="vipBean" />
  32. </beans>
复制代码
  1. package com.powernode.spring6.test;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class Spring6Test {<?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>@Test<?xml version="1.0" encoding="UTF-8"?>
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  10.     <bean id="vipBean" />
  11. </beans>public void testFirst(){<?xml version="1.0" encoding="UTF-8"?>
  12. <beans xmlns="http://www.springframework.org/schema/beans"
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <beans xmlns="http://www.springframework.org/schema/beans"
  15.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  17.     <bean id="vipBean" />
  18. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <beans xmlns="http://www.springframework.org/schema/beans"
  21.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  23.     <bean id="vipBean" />
  24. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <beans xmlns="http://www.springframework.org/schema/beans"
  27.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  28.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  29.     <bean id="vipBean" />
  30. </beans><bean id="userBean2" ></bean>
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>
  37. </beans>// 初始化Spring容器上下文(解析beans.xml文件,创建所有的bean对象)<?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <beans xmlns="http://www.springframework.org/schema/beans"
  41.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  42.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43.     <bean id="vipBean" />
  44. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <beans xmlns="http://www.springframework.org/schema/beans"
  47.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  49.     <bean id="vipBean" />
  50. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  51. <?xml version="1.0" encoding="UTF-8"?>
  52. <beans xmlns="http://www.springframework.org/schema/beans"
  53.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  55.     <bean id="vipBean" />
  56. </beans><bean id="userBean2" ></bean>
  57. <?xml version="1.0" encoding="UTF-8"?>
  58. <beans xmlns="http://www.springframework.org/schema/beans"
  59.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  60.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  61.     <bean id="vipBean" />
  62. </beans>
  63. </beans>ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml","spring.xml");<?xml version="1.0" encoding="UTF-8"?>
  64. <beans xmlns="http://www.springframework.org/schema/beans"
  65. <?xml version="1.0" encoding="UTF-8"?>
  66. <beans xmlns="http://www.springframework.org/schema/beans"
  67.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  68.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  69.     <bean id="vipBean" />
  70. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  71. <?xml version="1.0" encoding="UTF-8"?>
  72. <beans xmlns="http://www.springframework.org/schema/beans"
  73.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  74.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  75.     <bean id="vipBean" />
  76. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77. <?xml version="1.0" encoding="UTF-8"?>
  78. <beans xmlns="http://www.springframework.org/schema/beans"
  79.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  80.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  81.     <bean id="vipBean" />
  82. </beans><bean id="userBean2" ></bean>
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  86.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  87.     <bean id="vipBean" />
  88. </beans>
  89. </beans>// 根据id获取bean对象<?xml version="1.0" encoding="UTF-8"?>
  90. <beans xmlns="http://www.springframework.org/schema/beans"
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <beans xmlns="http://www.springframework.org/schema/beans"
  99.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  101.     <bean id="vipBean" />
  102. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  107.     <bean id="vipBean" />
  108. </beans><bean id="userBean2" ></bean>
  109. <?xml version="1.0" encoding="UTF-8"?>
  110. <beans xmlns="http://www.springframework.org/schema/beans"
  111.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  113.     <bean id="vipBean" />
  114. </beans>
  115. </beans>Object userBean = applicationContext.getBean("userBean");<?xml version="1.0" encoding="UTF-8"?>
  116. <beans xmlns="http://www.springframework.org/schema/beans"
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><bean id="userBean2" ></bean>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139.     <bean id="vipBean" />
  140. </beans>
  141. </beans>Object vipBean = applicationContext.getBean("vipBean");<?xml version="1.0" encoding="UTF-8"?>
  142. <beans xmlns="http://www.springframework.org/schema/beans"
  143. <?xml version="1.0" encoding="UTF-8"?>
  144. <beans xmlns="http://www.springframework.org/schema/beans"
  145.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  146.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  147.     <bean id="vipBean" />
  148. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans><bean id="userBean2" ></bean>
  161. <?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans>
  167. </beans>Object dateBean = applicationContext.getBean("dateBean");<?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169. <?xml version="1.0" encoding="UTF-8"?>
  170. <beans xmlns="http://www.springframework.org/schema/beans"
  171.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  172.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  173.     <bean id="vipBean" />
  174. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  175. <?xml version="1.0" encoding="UTF-8"?>
  176. <beans xmlns="http://www.springframework.org/schema/beans"
  177.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  178.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  179.     <bean id="vipBean" />
  180. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans><bean id="userBean2" ></bean>
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>
  193. </beans>System.out.println(userBean);<?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195. <?xml version="1.0" encoding="UTF-8"?>
  196. <beans xmlns="http://www.springframework.org/schema/beans"
  197.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  198.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  199.     <bean id="vipBean" />
  200. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  201. <?xml version="1.0" encoding="UTF-8"?>
  202. <beans xmlns="http://www.springframework.org/schema/beans"
  203.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  204.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  205.     <bean id="vipBean" />
  206. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  207. <?xml version="1.0" encoding="UTF-8"?>
  208. <beans xmlns="http://www.springframework.org/schema/beans"
  209.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  210.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  211.     <bean id="vipBean" />
  212. </beans><bean id="userBean2" ></bean>
  213. <?xml version="1.0" encoding="UTF-8"?>
  214. <beans xmlns="http://www.springframework.org/schema/beans"
  215.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  216.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  217.     <bean id="vipBean" />
  218. </beans>
  219. </beans>System.out.println(vipBean);<?xml version="1.0" encoding="UTF-8"?>
  220. <beans xmlns="http://www.springframework.org/schema/beans"
  221. <?xml version="1.0" encoding="UTF-8"?>
  222. <beans xmlns="http://www.springframework.org/schema/beans"
  223.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  224.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  225.     <bean id="vipBean" />
  226. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  227. <?xml version="1.0" encoding="UTF-8"?>
  228. <beans xmlns="http://www.springframework.org/schema/beans"
  229.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  230.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  231.     <bean id="vipBean" />
  232. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  233. <?xml version="1.0" encoding="UTF-8"?>
  234. <beans xmlns="http://www.springframework.org/schema/beans"
  235.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  236.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  237.     <bean id="vipBean" />
  238. </beans><bean id="userBean2" ></bean>
  239. <?xml version="1.0" encoding="UTF-8"?>
  240. <beans xmlns="http://www.springframework.org/schema/beans"
  241.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  242.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  243.     <bean id="vipBean" />
  244. </beans>
  245. </beans>System.out.println(dateBean);<?xml version="1.0" encoding="UTF-8"?>
  246. <beans xmlns="http://www.springframework.org/schema/beans"
  247.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  248.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  249.     <bean id="vipBean" />
  250. </beans>}}
复制代码
运行测试程序:

通过测试得知,在spring配置文件中配置的bean可以任意类,只要这个类不是抽象的,并且提供了无参数构造方法。
4.6 getBean()方法调用时,如果指定的id不存在会怎样?


运行测试程序:

通过测试得知,当id不存在的时候,会出现异常。
4.7  getBean()方法返回的类型是Object,如果访问子类的特有属性和方法时,还需要向下转型,有其它办法可以解决这个问题吗?
  1. User user = applicationContext.getBean("userBean", User.class);
复制代码
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.     <bean id="vipBean" />
  6. </beans>ApplicationContext applicationContext2 = new FileSystemXmlApplicationContext("d:/spring6.xml");
  7. Vip vip = applicationContext2.getBean("vipBean2", Vip.class);
  8. System.out.println(vip);
复制代码
没有在类路径中的话,需要使用FileSystemXmlApplicationContext类进行加载配置文件。注意: 如果在类的路径当中,读取到的是类路径下的子目录下的 xml 文件信息,需要指明对应的 类路径下的子目录,不然无法读取到其中的 xml 文件信息的。
这种方式较少用。一般都是将配置文件放到类路径当中,这样可移植性更强。
4.8  ApplicationContext的超级父接口BeanFactory。
  1. BeanFactory beanFactory = new ClassPathXmlApplicationContext("spring.xml");
  2. Object vipBean = beanFactory.getBean("vipBean");
  3. System.out.println(vipBean);
复制代码
BeanFactory是Spring容器的超级接口。ApplicationContext是BeanFactory的子接口。

5. Spring6启用Log4j2日志框架

第一步:引入Log4j2的依赖
  1. <dependency>
  2.   <groupId>org.apache.logging.log4j</groupId>
  3.   <artifactId>log4j-core</artifactId>
  4.   <version>2.19.0</version>
  5. </dependency>
  6. <dependency>
  7.   <groupId>org.apache.logging.log4j</groupId>
  8.   <artifactId>log4j-slf4j2-impl</artifactId>
  9.   <version>2.19.0</version>
  10. </dependency>
复制代码
第二步:在类的根路径下提供log4j2.xml配置文件(文件名固定为:log4j2.xml,文件必须放到类根路径下。)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  7.     <bean id="vipBean" />
  8. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. <?xml version="1.0" encoding="UTF-8"?>
  10. <beans xmlns="http://www.springframework.org/schema/beans"
  11.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  12.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  13.     <bean id="vipBean" />
  14. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  15. <?xml version="1.0" encoding="UTF-8"?>
  16. <beans xmlns="http://www.springframework.org/schema/beans"
  17.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  18.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  19.     <bean id="vipBean" />
  20. </beans><bean id="userBean2" ></bean>
  21. <?xml version="1.0" encoding="UTF-8"?>
  22. <beans xmlns="http://www.springframework.org/schema/beans"
  23.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  24.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  25.     <bean id="vipBean" />
  26. </beans>
  27. </beans><?xml version="1.0" encoding="UTF-8"?>
  28. <beans xmlns="http://www.springframework.org/schema/beans"
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  32.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  33.     <bean id="vipBean" />
  34. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <beans xmlns="http://www.springframework.org/schema/beans"
  37.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  39.     <bean id="vipBean" />
  40. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41. <?xml version="1.0" encoding="UTF-8"?>
  42. <beans xmlns="http://www.springframework.org/schema/beans"
  43.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  45.     <bean id="vipBean" />
  46. </beans><bean id="userBean2" ></bean>
  47. <?xml version="1.0" encoding="UTF-8"?>
  48. <beans xmlns="http://www.springframework.org/schema/beans"
  49.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  50.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  51.     <bean id="vipBean" />
  52. </beans>
  53. </beans><?xml version="1.0" encoding="UTF-8"?>
  54. <beans xmlns="http://www.springframework.org/schema/beans"
  55. <?xml version="1.0" encoding="UTF-8"?>
  56. <beans xmlns="http://www.springframework.org/schema/beans"
  57.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  58.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  59.     <bean id="vipBean" />
  60. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  61. <?xml version="1.0" encoding="UTF-8"?>
  62. <beans xmlns="http://www.springframework.org/schema/beans"
  63.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  64.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  65.     <bean id="vipBean" />
  66. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  67. <?xml version="1.0" encoding="UTF-8"?>
  68. <beans xmlns="http://www.springframework.org/schema/beans"
  69.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  70.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  71.     <bean id="vipBean" />
  72. </beans><bean id="userBean2" ></bean>
  73. <?xml version="1.0" encoding="UTF-8"?>
  74. <beans xmlns="http://www.springframework.org/schema/beans"
  75.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  76.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  77.     <bean id="vipBean" />
  78. </beans>
  79. </beans><?xml version="1.0" encoding="UTF-8"?>
  80. <beans xmlns="http://www.springframework.org/schema/beans"
  81. <?xml version="1.0" encoding="UTF-8"?>
  82. <beans xmlns="http://www.springframework.org/schema/beans"
  83.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  84.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  85.     <bean id="vipBean" />
  86. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  87. <?xml version="1.0" encoding="UTF-8"?>
  88. <beans xmlns="http://www.springframework.org/schema/beans"
  89.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  90.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  91.     <bean id="vipBean" />
  92. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  93. <?xml version="1.0" encoding="UTF-8"?>
  94. <beans xmlns="http://www.springframework.org/schema/beans"
  95.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  96.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  97.     <bean id="vipBean" />
  98. </beans><bean id="userBean2" ></bean>
  99. <?xml version="1.0" encoding="UTF-8"?>
  100. <beans xmlns="http://www.springframework.org/schema/beans"
  101.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  102.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  103.     <bean id="vipBean" />
  104. </beans>
  105. </beans><?xml version="1.0" encoding="UTF-8"?>
  106. <beans xmlns="http://www.springframework.org/schema/beans"
  107. <?xml version="1.0" encoding="UTF-8"?>
  108. <beans xmlns="http://www.springframework.org/schema/beans"
  109.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  110.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  111.     <bean id="vipBean" />
  112. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  113. <?xml version="1.0" encoding="UTF-8"?>
  114. <beans xmlns="http://www.springframework.org/schema/beans"
  115.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  116.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  117.     <bean id="vipBean" />
  118. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  119. <?xml version="1.0" encoding="UTF-8"?>
  120. <beans xmlns="http://www.springframework.org/schema/beans"
  121.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  122.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  123.     <bean id="vipBean" />
  124. </beans><bean id="userBean2" ></bean>
  125. <?xml version="1.0" encoding="UTF-8"?>
  126. <beans xmlns="http://www.springframework.org/schema/beans"
  127.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  128.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129.     <bean id="vipBean" />
  130. </beans>
  131. </beans><?xml version="1.0" encoding="UTF-8"?>
  132. <beans xmlns="http://www.springframework.org/schema/beans"
  133. <?xml version="1.0" encoding="UTF-8"?>
  134. <beans xmlns="http://www.springframework.org/schema/beans"
  135.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  136.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  137.     <bean id="vipBean" />
  138. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  139. <?xml version="1.0" encoding="UTF-8"?>
  140. <beans xmlns="http://www.springframework.org/schema/beans"
  141.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  142.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  143.     <bean id="vipBean" />
  144. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  145. <?xml version="1.0" encoding="UTF-8"?>
  146. <beans xmlns="http://www.springframework.org/schema/beans"
  147.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  148.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  149.     <bean id="vipBean" />
  150. </beans><bean id="userBean2" ></bean>
  151. <?xml version="1.0" encoding="UTF-8"?>
  152. <beans xmlns="http://www.springframework.org/schema/beans"
  153.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  154.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  155.     <bean id="vipBean" />
  156. </beans>
  157. </beans><?xml version="1.0" encoding="UTF-8"?>
  158. <beans xmlns="http://www.springframework.org/schema/beans"
  159. <?xml version="1.0" encoding="UTF-8"?>
  160. <beans xmlns="http://www.springframework.org/schema/beans"
  161.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  162.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  163.     <bean id="vipBean" />
  164. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  165. <?xml version="1.0" encoding="UTF-8"?>
  166. <beans xmlns="http://www.springframework.org/schema/beans"
  167.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  168.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  169.     <bean id="vipBean" />
  170. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  171. <?xml version="1.0" encoding="UTF-8"?>
  172. <beans xmlns="http://www.springframework.org/schema/beans"
  173.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  174.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  175.     <bean id="vipBean" />
  176. </beans><bean id="userBean2" ></bean>
  177. <?xml version="1.0" encoding="UTF-8"?>
  178. <beans xmlns="http://www.springframework.org/schema/beans"
  179.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  180.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  181.     <bean id="vipBean" />
  182. </beans>
  183. </beans><?xml version="1.0" encoding="UTF-8"?>
  184. <beans xmlns="http://www.springframework.org/schema/beans"
  185. <?xml version="1.0" encoding="UTF-8"?>
  186. <beans xmlns="http://www.springframework.org/schema/beans"
  187.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  188.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  189.     <bean id="vipBean" />
  190. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  191. <?xml version="1.0" encoding="UTF-8"?>
  192. <beans xmlns="http://www.springframework.org/schema/beans"
  193.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  194.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  195.     <bean id="vipBean" />
  196. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  197. <?xml version="1.0" encoding="UTF-8"?>
  198. <beans xmlns="http://www.springframework.org/schema/beans"
  199.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  200.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  201.     <bean id="vipBean" />
  202. </beans><bean id="userBean2" ></bean>
  203. <?xml version="1.0" encoding="UTF-8"?>
  204. <beans xmlns="http://www.springframework.org/schema/beans"
  205.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  206.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  207.     <bean id="vipBean" />
  208. </beans>
  209. </beans><?xml version="1.0" encoding="UTF-8"?>
  210. <beans xmlns="http://www.springframework.org/schema/beans"
  211. <?xml version="1.0" encoding="UTF-8"?>
  212. <beans xmlns="http://www.springframework.org/schema/beans"
  213.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  214.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  215.     <bean id="vipBean" />
  216. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  217. <?xml version="1.0" encoding="UTF-8"?>
  218. <beans xmlns="http://www.springframework.org/schema/beans"
  219.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  220.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  221.     <bean id="vipBean" />
  222. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  223. <?xml version="1.0" encoding="UTF-8"?>
  224. <beans xmlns="http://www.springframework.org/schema/beans"
  225.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  226.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  227.     <bean id="vipBean" />
  228. </beans><bean id="userBean2" ></bean>
  229. <?xml version="1.0" encoding="UTF-8"?>
  230. <beans xmlns="http://www.springframework.org/schema/beans"
  231.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  232.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  233.     <bean id="vipBean" />
  234. </beans>
  235. </beans><?xml version="1.0" encoding="UTF-8"?>
  236. <beans xmlns="http://www.springframework.org/schema/beans"
  237. <?xml version="1.0" encoding="UTF-8"?>
  238. <beans xmlns="http://www.springframework.org/schema/beans"
  239.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  240.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  241.     <bean id="vipBean" />
  242. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  243. <?xml version="1.0" encoding="UTF-8"?>
  244. <beans xmlns="http://www.springframework.org/schema/beans"
  245.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  246.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  247.     <bean id="vipBean" />
  248. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  249. <?xml version="1.0" encoding="UTF-8"?>
  250. <beans xmlns="http://www.springframework.org/schema/beans"
  251.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  252.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  253.     <bean id="vipBean" />
  254. </beans><bean id="userBean2" ></bean>
  255. <?xml version="1.0" encoding="UTF-8"?>
  256. <beans xmlns="http://www.springframework.org/schema/beans"
  257.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  258.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  259.     <bean id="vipBean" />
  260. </beans>
  261. </beans><?xml version="1.0" encoding="UTF-8"?>
  262. <beans xmlns="http://www.springframework.org/schema/beans"
  263. <?xml version="1.0" encoding="UTF-8"?>
  264. <beans xmlns="http://www.springframework.org/schema/beans"
  265.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  266.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  267.     <bean id="vipBean" />
  268. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  269. <?xml version="1.0" encoding="UTF-8"?>
  270. <beans xmlns="http://www.springframework.org/schema/beans"
  271.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  272.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  273.     <bean id="vipBean" />
  274. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  275. <?xml version="1.0" encoding="UTF-8"?>
  276. <beans xmlns="http://www.springframework.org/schema/beans"
  277.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  278.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  279.     <bean id="vipBean" />
  280. </beans><bean id="userBean2" ></bean>
  281. <?xml version="1.0" encoding="UTF-8"?>
  282. <beans xmlns="http://www.springframework.org/schema/beans"
  283.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  284.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  285.     <bean id="vipBean" />
  286. </beans>
  287. </beans><?xml version="1.0" encoding="UTF-8"?>
  288. <beans xmlns="http://www.springframework.org/schema/beans"
  289. <?xml version="1.0" encoding="UTF-8"?>
  290. <beans xmlns="http://www.springframework.org/schema/beans"
  291.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  292.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  293.     <bean id="vipBean" />
  294. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  295. <?xml version="1.0" encoding="UTF-8"?>
  296. <beans xmlns="http://www.springframework.org/schema/beans"
  297.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  298.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  299.     <bean id="vipBean" />
  300. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  301. <?xml version="1.0" encoding="UTF-8"?>
  302. <beans xmlns="http://www.springframework.org/schema/beans"
  303.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  304.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  305.     <bean id="vipBean" />
  306. </beans><bean id="userBean2" ></bean>
  307. <?xml version="1.0" encoding="UTF-8"?>
  308. <beans xmlns="http://www.springframework.org/schema/beans"
  309.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  310.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  311.     <bean id="vipBean" />
  312. </beans>
  313. </beans><?xml version="1.0" encoding="UTF-8"?>
  314. <beans xmlns="http://www.springframework.org/schema/beans"
  315.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  316.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  317.     <bean id="vipBean" />
  318. </beans>
复制代码
第三步:使用日志框架
  1. Logger logger = LoggerFactory.getLogger(FirstSpringTest.class);
  2. logger.info("我是一条日志消息");
复制代码
6. 总结:

  1.   
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4. <?xml version="1.0" encoding="UTF-8"?>
  5. <beans xmlns="http://www.springframework.org/schema/beans"
  6.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  8.     <bean id="vipBean" />
  9. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. <?xml version="1.0" encoding="UTF-8"?>
  11. <beans xmlns="http://www.springframework.org/schema/beans"
  12.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  13.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  14.     <bean id="vipBean" />
  15. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  16. <?xml version="1.0" encoding="UTF-8"?>
  17. <beans xmlns="http://www.springframework.org/schema/beans"
  18.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  20.     <bean id="vipBean" />
  21. </beans><bean id="userBean2" ></bean>
  22. <?xml version="1.0" encoding="UTF-8"?>
  23. <beans xmlns="http://www.springframework.org/schema/beans"
  24.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  25.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  26.     <bean id="vipBean" />
  27. </beans>
  28. </beans>
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <beans xmlns="http://www.springframework.org/schema/beans"
  31. <?xml version="1.0" encoding="UTF-8"?>
  32. <beans xmlns="http://www.springframework.org/schema/beans"
  33.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  34.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  35.     <bean id="vipBean" />
  36. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <beans xmlns="http://www.springframework.org/schema/beans"
  39.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  40.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  41.     <bean id="vipBean" />
  42. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <beans xmlns="http://www.springframework.org/schema/beans"
  45.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  46.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  47.     <bean id="vipBean" />
  48. </beans><bean id="userBean2" ></bean>
  49. <?xml version="1.0" encoding="UTF-8"?>
  50. <beans xmlns="http://www.springframework.org/schema/beans"
  51.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  52.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  53.     <bean id="vipBean" />
  54. </beans>
  55. </beans>
  56. <?xml version="1.0" encoding="UTF-8"?>
  57. <beans xmlns="http://www.springframework.org/schema/beans"
  58. <?xml version="1.0" encoding="UTF-8"?>
  59. <beans xmlns="http://www.springframework.org/schema/beans"
  60.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  61.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  62.     <bean id="vipBean" />
  63. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  64. <?xml version="1.0" encoding="UTF-8"?>
  65. <beans xmlns="http://www.springframework.org/schema/beans"
  66.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  67.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  68.     <bean id="vipBean" />
  69. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  70. <?xml version="1.0" encoding="UTF-8"?>
  71. <beans xmlns="http://www.springframework.org/schema/beans"
  72.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  73.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  74.     <bean id="vipBean" />
  75. </beans><bean id="userBean2" ></bean>
  76. <?xml version="1.0" encoding="UTF-8"?>
  77. <beans xmlns="http://www.springframework.org/schema/beans"
  78.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  79.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  80.     <bean id="vipBean" />
  81. </beans>
  82. </beans><dependency>
  83. <?xml version="1.0" encoding="UTF-8"?>
  84. <beans xmlns="http://www.springframework.org/schema/beans"
  85. <?xml version="1.0" encoding="UTF-8"?>
  86. <beans xmlns="http://www.springframework.org/schema/beans"
  87.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  88.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  89.     <bean id="vipBean" />
  90. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  91. <?xml version="1.0" encoding="UTF-8"?>
  92. <beans xmlns="http://www.springframework.org/schema/beans"
  93.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  94.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  95.     <bean id="vipBean" />
  96. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <beans xmlns="http://www.springframework.org/schema/beans"
  99.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  101.     <bean id="vipBean" />
  102. </beans><bean id="userBean2" ></bean>
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <beans xmlns="http://www.springframework.org/schema/beans"
  105.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  106.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  107.     <bean id="vipBean" />
  108. </beans>
  109. </beans><?xml version="1.0" encoding="UTF-8"?>
  110. <beans xmlns="http://www.springframework.org/schema/beans"
  111.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  112.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  113.     <bean id="vipBean" />
  114. </beans><groupId>org.springframework</groupId>
  115. <?xml version="1.0" encoding="UTF-8"?>
  116. <beans xmlns="http://www.springframework.org/schema/beans"
  117. <?xml version="1.0" encoding="UTF-8"?>
  118. <beans xmlns="http://www.springframework.org/schema/beans"
  119.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  120.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  121.     <bean id="vipBean" />
  122. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  123. <?xml version="1.0" encoding="UTF-8"?>
  124. <beans xmlns="http://www.springframework.org/schema/beans"
  125.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  126.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  127.     <bean id="vipBean" />
  128. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  129. <?xml version="1.0" encoding="UTF-8"?>
  130. <beans xmlns="http://www.springframework.org/schema/beans"
  131.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  133.     <bean id="vipBean" />
  134. </beans><bean id="userBean2" ></bean>
  135. <?xml version="1.0" encoding="UTF-8"?>
  136. <beans xmlns="http://www.springframework.org/schema/beans"
  137.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  138.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  139.     <bean id="vipBean" />
  140. </beans>
  141. </beans><?xml version="1.0" encoding="UTF-8"?>
  142. <beans xmlns="http://www.springframework.org/schema/beans"
  143.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  144.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  145.     <bean id="vipBean" />
  146. </beans><artifactId>spring-context</artifactId>
  147. <?xml version="1.0" encoding="UTF-8"?>
  148. <beans xmlns="http://www.springframework.org/schema/beans"
  149. <?xml version="1.0" encoding="UTF-8"?>
  150. <beans xmlns="http://www.springframework.org/schema/beans"
  151.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  152.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  153.     <bean id="vipBean" />
  154. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  155. <?xml version="1.0" encoding="UTF-8"?>
  156. <beans xmlns="http://www.springframework.org/schema/beans"
  157.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  158.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  159.     <bean id="vipBean" />
  160. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  161. <?xml version="1.0" encoding="UTF-8"?>
  162. <beans xmlns="http://www.springframework.org/schema/beans"
  163.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  164.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  165.     <bean id="vipBean" />
  166. </beans><bean id="userBean2" ></bean>
  167. <?xml version="1.0" encoding="UTF-8"?>
  168. <beans xmlns="http://www.springframework.org/schema/beans"
  169.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  170.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  171.     <bean id="vipBean" />
  172. </beans>
  173. </beans><?xml version="1.0" encoding="UTF-8"?>
  174. <beans xmlns="http://www.springframework.org/schema/beans"
  175.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  176.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  177.     <bean id="vipBean" />
  178. </beans><version>6.0.3</version>
  179. <?xml version="1.0" encoding="UTF-8"?>
  180. <beans xmlns="http://www.springframework.org/schema/beans"
  181. <?xml version="1.0" encoding="UTF-8"?>
  182. <beans xmlns="http://www.springframework.org/schema/beans"
  183.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  184.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  185.     <bean id="vipBean" />
  186. </beans>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  187. <?xml version="1.0" encoding="UTF-8"?>
  188. <beans xmlns="http://www.springframework.org/schema/beans"
  189.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  190.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  191.     <bean id="vipBean" />
  192. </beans>   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  193. <?xml version="1.0" encoding="UTF-8"?>
  194. <beans xmlns="http://www.springframework.org/schema/beans"
  195.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  196.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  197.     <bean id="vipBean" />
  198. </beans><bean id="userBean2" ></bean>
  199. <?xml version="1.0" encoding="UTF-8"?>
  200. <beans xmlns="http://www.springframework.org/schema/beans"
  201.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  202.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  203.     <bean id="vipBean" />
  204. </beans>
  205. </beans></dependency>
复制代码
  1. ApplicationContext applicationContext2 = new FileSystemXmlApplicationContext("d:/spring6.xml");
  2. Vip vip = applicationContext2.getBean("vipBean2", Vip.class);
  3. System.out.println(vip);
复制代码
7. 最后:

“在这个最后的篇章中,我要表达我对每一位读者的感激之情。你们的关注和回复是我创作的动力源泉,我从你们身上吸取了无尽的灵感与勇气。我会将你们的鼓励留在心底,继续在其他的领域奋斗。感谢你们,我们总会在某个时刻再次相遇。”


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4