Qing 1 anno fa
parent
commit
d6952d748f
70 ha cambiato i file con 1096 aggiunte e 100 eliminazioni
  1. 121 46
      spring-demo/.idea/workspace.xml
  2. 13 0
      spring-demo/pom.xml
  3. 15 0
      spring-demo/src/main/java/com/sf/SpringConfig.java
  4. 16 0
      spring-demo/src/main/java/com/sf/anno/Box.java
  5. 39 0
      spring-demo/src/main/java/com/sf/anno/Chair.java
  6. 17 0
      spring-demo/src/main/java/com/sf/anno/Desk.java
  7. 50 0
      spring-demo/src/main/java/com/sf/anno/House.java
  8. 6 0
      spring-demo/src/main/java/com/sf/anno/Plane.java
  9. 32 0
      spring-demo/src/main/java/com/sf/anno/Teacher.java
  10. 34 0
      spring-demo/src/main/java/com/sf/auto/Chair.java
  11. 37 0
      spring-demo/src/main/java/com/sf/auto/House.java
  12. 29 0
      spring-demo/src/main/java/com/sf/auto/Teacher.java
  13. 48 0
      spring-demo/src/main/java/com/sf/car/Car.java
  14. 23 0
      spring-demo/src/main/java/com/sf/car/CarInstanceFactory.java
  15. 22 0
      spring-demo/src/main/java/com/sf/car/CarStaticFactory.java
  16. 27 0
      spring-demo/src/main/java/com/sf/factory/Computer.java
  17. 11 0
      spring-demo/src/main/java/com/sf/factory/Output.java
  18. 27 0
      spring-demo/src/main/java/com/sf/factory/OutputFactory.java
  19. 14 0
      spring-demo/src/main/java/com/sf/factory/printer/BetterPrinter.java
  20. 14 0
      spring-demo/src/main/java/com/sf/factory/printer/Printer.java
  21. 14 0
      spring-demo/src/main/java/com/sf/factory/shape/Shape.java
  22. 9 0
      spring-demo/src/main/java/com/sf/factory/shape/Triangle.java
  23. 1 1
      spring-demo/src/main/java/com/sf/helloworld/Auth.java
  24. 1 1
      spring-demo/src/main/java/com/sf/helloworld/Role.java
  25. 1 1
      spring-demo/src/main/java/com/sf/helloworld/User.java
  26. 16 0
      spring-demo/src/main/java/com/sf/javase/anno/Column.java
  27. 36 0
      spring-demo/src/main/java/com/sf/javase/anno/Student.java
  28. 13 0
      spring-demo/src/main/java/com/sf/javase/anno/Table.java
  29. 45 0
      spring-demo/src/main/java/com/sf/javase/anno/TestStudent.java
  30. 5 0
      spring-demo/src/main/java/com/sf/javase/anno/hello/Check.java
  31. 7 0
      spring-demo/src/main/java/com/sf/javase/anno/hello/Test.java
  32. 19 0
      spring-demo/src/main/java/com/sf/javase/anno/hello/TestAnnotation.java
  33. 1 1
      spring-demo/src/main/java/com/sf/javase/base/Main.java
  34. 1 1
      spring-demo/src/main/java/com/sf/javase/base/StaticInterview.java
  35. 1 1
      spring-demo/src/main/java/com/sf/javase/base/TestCollection.java
  36. 1 1
      spring-demo/src/main/java/com/sf/javase/base/TestMath.java
  37. 1 1
      spring-demo/src/main/java/com/sf/javase/base/TestString.java
  38. 1 1
      spring-demo/src/main/java/com/sf/javase/base/TestStringIntern.java
  39. 11 0
      spring-demo/src/main/java/com/sf/javase/computer/Computer.java
  40. 32 0
      spring-demo/src/main/java/com/sf/javase/computer/ComputerFactory.java
  41. 9 0
      spring-demo/src/main/java/com/sf/javase/computer/IComputerFactory.java
  42. 11 0
      spring-demo/src/main/java/com/sf/javase/computer/MacComputer.java
  43. 12 0
      spring-demo/src/main/java/com/sf/javase/computer/MacComputerFactory.java
  44. 11 0
      spring-demo/src/main/java/com/sf/javase/computer/MiComputer.java
  45. 8 0
      spring-demo/src/main/java/com/sf/javase/computer/MiComputerFactory.java
  46. 14 0
      spring-demo/src/main/java/com/sf/javase/computer/Test.java
  47. 2 4
      spring-demo/src/main/java/com/sf/javase/reflect/TestReflect.java
  48. 1 1
      spring-demo/src/main/java/com/sf/javase/reflect/TestUser.java
  49. 1 1
      spring-demo/src/main/java/com/sf/javase/reflect/TestUserByHCB.java
  50. 1 1
      spring-demo/src/main/java/com/sf/javase/reflect/User.java
  51. 1 1
      spring-demo/src/main/java/com/sf/javase/singleton/Singleton1.java
  52. 1 1
      spring-demo/src/main/java/com/sf/javase/singleton/Singleton2.java
  53. 1 1
      spring-demo/src/main/java/com/sf/javase/singleton/Singleton3.java
  54. 1 1
      spring-demo/src/main/java/com/sf/javase/singleton/Singleton4.java
  55. 1 1
      spring-demo/src/main/java/com/sf/javase/singleton/TestSingleton.java
  56. 1 1
      spring-demo/src/main/java/com/sf/self/BeanDefined.java
  57. 1 1
      spring-demo/src/main/java/com/sf/self/BeanFactory.java
  58. 5 7
      spring-demo/src/main/java/com/sf/self/Test.java
  59. 13 0
      spring-demo/src/main/resources/spring-annotation.xml
  60. 16 0
      spring-demo/src/main/resources/spring-auto.xml
  61. 8 8
      spring-demo/src/main/resources/spring-beans-new.xml
  62. 7 7
      spring-demo/src/main/resources/spring-beans.xml
  63. 49 0
      spring-demo/src/main/resources/spring-factory.xml
  64. 3 3
      spring-demo/src/main/resources/spring-singleton.xml
  65. 21 0
      spring-demo/src/test/java/com/sf/TestAnno.java
  66. 30 0
      spring-demo/src/test/java/com/sf/TestAuto.java
  67. 21 0
      spring-demo/src/test/java/com/sf/TestConfig.java
  68. 25 0
      spring-demo/src/test/java/com/sf/TestFactory.java
  69. 4 2
      spring-demo/src/test/java/com/sf/TestSingleton.java
  70. 6 4
      spring-demo/src/test/java/com/sf/TestUser.java

+ 121 - 46
spring-demo/.idea/workspace.xml

@@ -4,18 +4,77 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5aa6272e-23b4-48f4-9aaa-8caf45810aa0" name="Changes" comment="0417 spring">
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/lifecycle/MyBeanPost.java" afterDir="false" />
+    <list default="true" id="5aa6272e-23b4-48f4-9aaa-8caf45810aa0" name="Changes" comment="0420 spring lifecycle">
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/SpringConfig.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/Box.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/Chair.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/Desk.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/House.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/Plane.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/anno/Teacher.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/auto/Chair.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/auto/House.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/auto/Teacher.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/car/Car.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/car/CarInstanceFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/car/CarStaticFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/Computer.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/Output.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/OutputFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/printer/BetterPrinter.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/printer/Printer.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/shape/Shape.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/shape/Triangle.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/Column.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/Student.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/Table.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/TestStudent.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/hello/Check.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/hello/Test.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/anno/hello/TestAnnotation.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/Computer.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/ComputerFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/IComputerFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/MacComputer.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/MacComputerFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/MiComputer.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/MiComputerFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/computer/Test.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-annotation.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-auto.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-factory.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestAnno.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestAuto.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestConfig.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestFactory.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/Auth.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/Auth.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/User.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton1.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton2.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton2.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton3.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton3.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/Auth.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/helloworld/Auth.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/Role.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/helloworld/Role.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/helloworld/User.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/Main.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/StaticInterview.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/StaticInterview.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/TestCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/TestCollection.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/TestMath.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/TestMath.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/TestString.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/TestString.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/javase/TestStringIntern.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/base/TestStringIntern.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/reflect/TestReflect.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/reflect/TestReflect.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/reflect/TestUser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/reflect/TestUser.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/reflect/TestUserByHCB.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/reflect/TestUserByHCB.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/reflect/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/reflect/User.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanDefined.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanDefined.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanFactory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanFactory.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/self/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/Test.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/singleton/Singleton1.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton2.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/singleton/Singleton2.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton3.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/singleton/Singleton3.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton4.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/singleton/Singleton4.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/singleton/TestSingleton.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/javase/singleton/TestSingleton.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/resources/spring-beans-new.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/spring-beans-new.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/resources/spring-beans.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/spring-beans.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/resources/spring-singleton.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/spring-singleton.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/test/java/com/sf/TestSingleton.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestSingleton.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/test/java/com/sf/TestUser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestUser.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -31,7 +90,9 @@
     <option name="RECENT_TEMPLATES">
       <list>
         <option value="Spring File" />
+        <option value="AnnotationType" />
         <option value="Spring Xml File" />
+        <option value="Interface" />
         <option value="Class" />
       </list>
     </option>
@@ -51,7 +112,9 @@
   </component>
   <component name="PropertiesComponent"><![CDATA[{
   "keyToString": {
+    "Application.ComputerFactory.executor": "Run",
     "Application.Main.executor": "Run",
+    "Application.OutputFactory.executor": "Run",
     "Application.StaticInterview.executor": "Run",
     "Application.Test.executor": "Run",
     "Application.TestCollection (1).executor": "Run",
@@ -62,8 +125,16 @@
     "Application.TestSingleton.executor": "Run",
     "Application.TestString.executor": "Run",
     "Application.TestStringIntern.executor": "Run",
+    "Application.TestStudent.executor": "Run",
     "Application.TestUser.executor": "Run",
     "Application.TestUserByHCB.executor": "Run",
+    "Application.com.sf.factory.Test.executor": "Run",
+    "JUnit.TestAnno.executor": "Run",
+    "JUnit.TestAnno.test.executor": "Run",
+    "JUnit.TestAnno.testAnno.executor": "Run",
+    "JUnit.TestAuto.test.executor": "Run",
+    "JUnit.TestConfig.test.executor": "Run",
+    "JUnit.TestFactory.test.executor": "Run",
     "JUnit.TestSingleton.test.executor": "Run",
     "JUnit.TestSingleton.testLife.executor": "Run",
     "JUnit.TestUser.executor": "Run",
@@ -92,80 +163,75 @@
     <key name="CopyFile.RECENT_KEYS">
       <recent name="$PROJECT_DIR$/src/main/resources" />
     </key>
+    <key name="CopyClassDialog.RECENTS_KEY">
+      <recent name="com.sf.anno" />
+    </key>
   </component>
-  <component name="RunManager" selected="JUnit.TestSingleton.testLife">
-    <configuration name="Test" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
-      <option name="MAIN_CLASS_NAME" value="com.sf.self.Test" />
-      <module name="spring-demo" />
-      <extension name="coverage">
-        <pattern>
-          <option name="PATTERN" value="com.sf.self.*" />
-          <option name="ENABLED" value="true" />
-        </pattern>
-      </extension>
-      <method v="2">
-        <option name="Make" enabled="true" />
-      </method>
-    </configuration>
-    <configuration name="TestCollection" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
-      <option name="MAIN_CLASS_NAME" value="com.sf.javase.TestCollection" />
+  <component name="RunManager" selected="JUnit.TestConfig.test">
+    <configuration name="TestAnno" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.javase.*" />
+          <option name="PATTERN" value="com.sf.helloworld.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
+      <option name="PACKAGE_NAME" value="com.sf" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestAnno" />
+      <option name="TEST_OBJECT" value="class" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestSingleton" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
-      <option name="MAIN_CLASS_NAME" value="com.sf.singleton.TestSingleton" />
+    <configuration name="TestAnno.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.singleton.*" />
+          <option name="PATTERN" value="com.sf.helloworld.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
+      <option name="PACKAGE_NAME" value="com.sf" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestAnno" />
+      <option name="METHOD_NAME" value="test" />
+      <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestSingleton.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TestAnno.testAnno" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.helloworld.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.TestSingleton" />
-      <option name="METHOD_NAME" value="test" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestAnno" />
+      <option name="METHOD_NAME" value="testAnno" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestSingleton.testLife" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TestAuto.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.helloworld.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.TestSingleton" />
-      <option name="METHOD_NAME" value="testLife" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestAuto" />
+      <option name="METHOD_NAME" value="test" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestUser.testNew" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TestConfig.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
@@ -174,8 +240,8 @@
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.TestUser" />
-      <option name="METHOD_NAME" value="testNew" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestConfig" />
+      <option name="METHOD_NAME" value="test" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
@@ -183,11 +249,11 @@
     </configuration>
     <recent_temporary>
       <list>
-        <item itemvalue="JUnit.TestSingleton.testLife" />
-        <item itemvalue="Application.Test" />
-        <item itemvalue="JUnit.TestSingleton.test" />
-        <item itemvalue="Application.TestSingleton" />
-        <item itemvalue="JUnit.TestUser.testNew" />
+        <item itemvalue="JUnit.TestConfig.test" />
+        <item itemvalue="JUnit.TestAnno" />
+        <item itemvalue="JUnit.TestAnno.testAnno" />
+        <item itemvalue="JUnit.TestAuto.test" />
+        <item itemvalue="JUnit.TestAnno.test" />
       </list>
     </recent_temporary>
   </component>
@@ -205,7 +271,7 @@
       <workItem from="1712972174804" duration="14892000" />
       <workItem from="1713086100573" duration="122000" />
       <workItem from="1713332000735" duration="13027000" />
-      <workItem from="1713574818502" duration="3271000" />
+      <workItem from="1713574818502" duration="19370000" />
     </task>
     <task id="LOCAL-00001" summary="0403 javaSE">
       <option name="closed" value="true" />
@@ -247,7 +313,15 @@
       <option name="project" value="LOCAL" />
       <updated>1713344510906</updated>
     </task>
-    <option name="localTasksCounter" value="6" />
+    <task id="LOCAL-00006" summary="0420 spring lifecycle">
+      <option name="closed" value="true" />
+      <created>1713578306388</created>
+      <option name="number" value="00006" />
+      <option name="presentableId" value="LOCAL-00006" />
+      <option name="project" value="LOCAL" />
+      <updated>1713578306388</updated>
+    </task>
+    <option name="localTasksCounter" value="7" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -351,7 +425,8 @@
     <MESSAGE value="0410 reflect" />
     <MESSAGE value="0413 spring" />
     <MESSAGE value="0417 spring" />
-    <option name="LAST_COMMIT_MESSAGE" value="0417 spring" />
+    <MESSAGE value="0420 spring lifecycle" />
+    <option name="LAST_COMMIT_MESSAGE" value="0420 spring lifecycle" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />

+ 13 - 0
spring-demo/pom.xml

@@ -22,6 +22,19 @@
             <artifactId>spring-context</artifactId>
             <version>6.1.5</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>6.1.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jakarta.annotation</groupId>
+            <artifactId>jakarta.annotation-api</artifactId>
+            <version>3.0.0</version>
+        </dependency>
+
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter</artifactId>

+ 15 - 0
spring-demo/src/main/java/com/sf/SpringConfig.java

@@ -0,0 +1,15 @@
+package com.sf;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Configuration 代表是spring的配置项
+ * 代替一个xml文件
+ * <context:component-scan base-package="com.sf.anno">
+ *     </context:component-scan>
+ */
+@Configuration
+@ComponentScan("com.sf.anno")
+public class SpringConfig {
+}

+ 16 - 0
spring-demo/src/main/java/com/sf/anno/Box.java

@@ -0,0 +1,16 @@
+package com.sf.anno;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class Box implements Plane{
+    @Override
+    public void put() {
+        System.out.println("this is box");
+    }
+
+    @Override
+    public String toString() {
+        return "Box{}";
+    }
+}

+ 39 - 0
spring-demo/src/main/java/com/sf/anno/Chair.java

@@ -0,0 +1,39 @@
+package com.sf.anno;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 椅子
+ */
+@Component
+public class Chair {
+
+    public Chair() {
+        System.out.println("Chair 构造器");
+    }
+
+    /**
+     * 椅子上有一位老师
+     *   类别  名字
+     * Teacher teacher;
+     */
+    @Autowired
+    private Teacher teacher;
+
+    public Teacher getTeacher() {
+        return teacher;
+    }
+
+    public void setTeacher(Teacher teacher) {
+        System.out.println("Chair setTeacher");
+        this.teacher = teacher;
+    }
+
+    @Override
+    public String toString() {
+        return "Chair{" +
+                "teacher=" + teacher +
+                '}';
+    }
+}

+ 17 - 0
spring-demo/src/main/java/com/sf/anno/Desk.java

@@ -0,0 +1,17 @@
+package com.sf.anno;
+
+import org.springframework.stereotype.Component;
+
+// <bean id="desk" class="com.sf.anno.Desk"/>
+@Component
+public class Desk implements Plane{
+    @Override
+    public void put() {
+        System.out.println("this is desk");
+    }
+
+    @Override
+    public String toString() {
+        return "Desk{}";
+    }
+}

+ 50 - 0
spring-demo/src/main/java/com/sf/anno/House.java

@@ -0,0 +1,50 @@
+package com.sf.anno;
+
+import jakarta.annotation.Resource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+/**
+ * 教室
+ * 构造类和类之间的组合关系  区别于继承关系
+ */
+@Component
+// <bean id="house">
+public class House {
+
+    /**
+     * 教室里有一把椅子
+     */
+    @Autowired
+    private Chair chair;
+
+    // 使用@Autowired 是先根据类型来匹配对象
+    //   如果类型对应的对象有多个 可以结合 @Qualifier来声明名字
+    // 使用@Resource 是先根据名字来匹配对象
+    // Could not autowire. There is more than one bean of 'Plane' type.
+//    @Autowired @Qualifier("desk")
+//    @Autowired @Qualifier("box")
+
+//    @Resource(name = "desk")
+//    private Plane plane;
+    @Resource
+    private Plane desk;
+
+    public House() {
+        System.out.println("House 构造器");
+    }
+
+    public void setChair(Chair chair) {
+        System.out.println("House setChair");
+        this.chair = chair;
+    }
+
+    @Override
+    public String toString() {
+        return "House{" +
+                "chair=" + chair +
+                ", plane=" + desk +
+                '}';
+    }
+}

+ 6 - 0
spring-demo/src/main/java/com/sf/anno/Plane.java

@@ -0,0 +1,6 @@
+package com.sf.anno;
+
+// 平面
+public interface Plane {
+    void put();
+}

+ 32 - 0
spring-demo/src/main/java/com/sf/anno/Teacher.java

@@ -0,0 +1,32 @@
+package com.sf.anno;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * 老师
+ */
+@Component
+public class Teacher {
+
+    public Teacher() {
+        System.out.println("Teacher 构造器");
+    }
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        System.out.println("Teacher setName");
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Teacher{" +
+                "name='" + name + '\'' +
+                '}';
+    }
+}

+ 34 - 0
spring-demo/src/main/java/com/sf/auto/Chair.java

@@ -0,0 +1,34 @@
+package com.sf.auto;
+
+/**
+ * 椅子
+ */
+public class Chair {
+
+    public Chair() {
+        System.out.println("Chair 构造器");
+    }
+
+    /**
+     * 椅子上有一位老师
+     *   类别  名字
+     * Teacher teacher;
+     */
+    private Teacher teacher;
+
+    public Teacher getTeacher() {
+        return teacher;
+    }
+
+    public void setTeacher(Teacher teacher) {
+        System.out.println("Chair setTeacher");
+        this.teacher = teacher;
+    }
+
+    @Override
+    public String toString() {
+        return "Chair{" +
+                "teacher=" + teacher +
+                '}';
+    }
+}

+ 37 - 0
spring-demo/src/main/java/com/sf/auto/House.java

@@ -0,0 +1,37 @@
+package com.sf.auto;
+
+/**
+ * 教室
+ * 构造类和类之间的组合关系  区别于继承关系
+ */
+public class House {
+
+    public House() {
+        System.out.println("House 构造器");
+    }
+
+    public House(Chair chair) {
+        this.chair = chair;
+    }
+
+    /**
+     * 教室里有一把椅子
+     */
+    private Chair chair;
+
+    public Chair getChair() {
+        return chair;
+    }
+
+    public void setChair(Chair chair) {
+        System.out.println("House setChair");
+        this.chair = chair;
+    }
+
+    @Override
+    public String toString() {
+        return "House{" +
+                "chair=" + chair +
+                '}';
+    }
+}

+ 29 - 0
spring-demo/src/main/java/com/sf/auto/Teacher.java

@@ -0,0 +1,29 @@
+package com.sf.auto;
+
+/**
+ * 老师
+ */
+public class Teacher {
+
+    public Teacher() {
+        System.out.println("Teacher 构造器");
+    }
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        System.out.println("Teacher setName");
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Teacher{" +
+                "name='" + name + '\'' +
+                '}';
+    }
+}

+ 48 - 0
spring-demo/src/main/java/com/sf/car/Car.java

@@ -0,0 +1,48 @@
+package com.sf.car;
+
+public class Car {
+
+    public Car() {
+
+    }
+
+    public Car(int id, String name, int price) {
+        super();
+        this.id = id;
+        this.name = name;
+        this.price = price;
+    }
+    private int id;
+    private String name;
+    private int price;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getPrice() {
+        return price;
+    }
+
+    public void setPrice(int price) {
+        this.price = price;
+    }
+
+    @Override
+    public String toString() {
+        return "Car [id=" + id + ", name=" + name + ", price=" + price + "]";
+    }
+
+}

+ 23 - 0
spring-demo/src/main/java/com/sf/car/CarInstanceFactory.java

@@ -0,0 +1,23 @@
+package com.sf.car;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 实例工厂 是存储对象的容器map 和获取对象的方法getCar() 都不是静态的
+ * 需要对象来获取
+ */
+public class CarInstanceFactory {
+    private Map<Integer, Car> map = new HashMap<Integer,Car>();
+ 
+    public void setMap(Map<Integer, Car> map) {
+        this.map = map;
+    }
+ 
+    public CarInstanceFactory(){
+    }
+ 
+    public Car getCar(int id){
+        return map.get(id);
+    }
+}

+ 22 - 0
spring-demo/src/main/java/com/sf/car/CarStaticFactory.java

@@ -0,0 +1,22 @@
+package com.sf.car;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 先把数据创建出来
+ * 只需要调用方法 就能获取到
+ */
+public class CarStaticFactory {
+    private static Map<Integer, Car> map = new HashMap<Integer, Car>();
+
+    static {
+        map.put(1, new Car(1, "Honda", 300000));
+        map.put(2, new Car(2, "Audi", 440000));
+        map.put(3, new Car(3, "BMW", 540000));
+    }
+
+    public static Car getCar(int id) {
+        return map.get(id);
+    }
+}

+ 27 - 0
spring-demo/src/main/java/com/sf/factory/Computer.java

@@ -0,0 +1,27 @@
+package com.sf.factory;
+
+import com.sf.factory.printer.Printer;
+
+/**
+ * 计算机
+ */
+public class Computer {
+    // 这种输出方式 只是计算机的使用方式之一
+    private Output output;
+
+//    private Printer printer;
+
+    public Computer(Output output) {
+        this.output = output;
+    }
+
+    public void setOutput(Output output) {
+        this.output = output;
+    }
+
+    // 提供计算机自己的打印方法
+    public void print(){
+        System.out.println("Computer print");
+        output.out();
+    }
+}

+ 11 - 0
spring-demo/src/main/java/com/sf/factory/Output.java

@@ -0,0 +1,11 @@
+package com.sf.factory;
+
+/**
+ * 模拟计算机连接打印机的使用方式
+ * 打印机的规范
+ */
+public interface Output {
+
+    // ctrl + alt 进入具体实现类
+    void out();
+}

+ 27 - 0
spring-demo/src/main/java/com/sf/factory/OutputFactory.java

@@ -0,0 +1,27 @@
+package com.sf.factory;
+
+import com.sf.factory.printer.BetterPrinter;
+import com.sf.factory.printer.Printer;
+
+/**
+ * 工厂类
+ * 叫做工厂模式
+ */
+public class OutputFactory {
+
+    // 获取打印方式  通过工厂来创建打印机
+    public Output getOutput(){
+        // 此时只需要获取一个 Output的实现类
+//        return new Printer();
+        return new BetterPrinter();
+    }
+
+    public static void main(String[] args) {
+        // 分别创建了 打印机和计算机
+//        Printer printer = new Printer();
+//        Computer computer = new Computer(printer);
+        OutputFactory factory = new OutputFactory();
+        Computer computer = new Computer(factory.getOutput());
+        computer.print();
+    }
+}

+ 14 - 0
spring-demo/src/main/java/com/sf/factory/printer/BetterPrinter.java

@@ -0,0 +1,14 @@
+package com.sf.factory.printer;
+
+import com.sf.factory.Output;
+
+/**
+ * 打印机升级了
+ */
+public class BetterPrinter implements Output {
+
+    @Override
+    public void out() {
+        System.out.println("BetterPrinter 更好的打印机");
+    }
+}

+ 14 - 0
spring-demo/src/main/java/com/sf/factory/printer/Printer.java

@@ -0,0 +1,14 @@
+package com.sf.factory.printer;
+
+import com.sf.factory.Output;
+
+/**
+ * 打印机
+ */
+public class Printer implements Output {
+
+    @Override
+    public void out() {
+        System.out.println("Printer 打印机");
+    }
+}

+ 14 - 0
spring-demo/src/main/java/com/sf/factory/shape/Shape.java

@@ -0,0 +1,14 @@
+package com.sf.factory.shape;
+
+/**
+ * 抽象类
+ * 是父类对子类的约束
+ *   抽象方法需要被子类实现
+ * 提供的是一种模版
+ * 是模版模式/模版方法模式
+ */
+public abstract class Shape {
+
+    // 周长
+    public abstract double perimeter();
+}

+ 9 - 0
spring-demo/src/main/java/com/sf/factory/shape/Triangle.java

@@ -0,0 +1,9 @@
+package com.sf.factory.shape;
+
+public class Triangle extends Shape{
+
+    @Override
+    public double perimeter() {
+        return 0;
+    }
+}

+ 1 - 1
spring-demo/src/main/java/com/sf/Auth.java → spring-demo/src/main/java/com/sf/helloworld/Auth.java

@@ -1,4 +1,4 @@
-package com.sf;
+package com.sf.helloworld;
 
 /**
  * 权限类

+ 1 - 1
spring-demo/src/main/java/com/sf/Role.java → spring-demo/src/main/java/com/sf/helloworld/Role.java

@@ -1,4 +1,4 @@
-package com.sf;
+package com.sf.helloworld;
 
 import java.util.Arrays;
 import java.util.List;

+ 1 - 1
spring-demo/src/main/java/com/sf/User.java → spring-demo/src/main/java/com/sf/helloworld/User.java

@@ -1,4 +1,4 @@
-package com.sf;
+package com.sf.helloworld;
 
 public class User {
     // User user = new User();

+ 16 - 0
spring-demo/src/main/java/com/sf/javase/anno/Column.java

@@ -0,0 +1,16 @@
+package com.sf.javase.anno;
+
+import java.lang.annotation.*;
+
+/**
+ * 字段
+ */
+@Inherited
+@Target(ElementType.FIELD)  //注解作用在属性上
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Column {
+    // 字段名
+    String columnName();
+    // 字段类型
+    String columnType();
+}

+ 36 - 0
spring-demo/src/main/java/com/sf/javase/anno/Student.java

@@ -0,0 +1,36 @@
+package com.sf.javase.anno;
+
+/**
+ * 通过注解 Table 声明这个字段对应数据库中的student表
+ */
+@Table("student_info")
+public class Student {
+    @Column(columnName = "s_id",columnType = "int")
+    private int id;
+    @Column(columnName = "s_name",columnType = "varchar(20)")
+    private String name;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Student{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                '}';
+    }
+}

+ 13 - 0
spring-demo/src/main/java/com/sf/javase/anno/Table.java

@@ -0,0 +1,13 @@
+package com.sf.javase.anno;
+
+import java.lang.annotation.*;
+
+/**
+ * 表
+ */
+@Inherited
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Table {
+    String value();
+}

+ 45 - 0
spring-demo/src/main/java/com/sf/javase/anno/TestStudent.java

@@ -0,0 +1,45 @@
+package com.sf.javase.anno;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * 通过注解 构造对表的查询语句
+ * 通过反射来获取注解中的值
+ * 然后进行逻辑处理 (注解+反射)
+ */
+public class TestStudent {
+
+    public static void main(String[] args) {
+        // 获取类对象
+        Class<Student> studentCls = Student.class;
+        // 接收类对象的所有注解
+        Annotation[] annotations = studentCls.getAnnotations();
+        // 能够指定注解的类型 拿到注解对象
+        // @Table("student")
+        Table table = studentCls.getAnnotation(Table.class);
+        // 可以通过注解对象 获取注解中配置的数据
+        String tableName = table.value();
+        System.out.println(tableName);
+
+        // 获取全部的属性 id name
+        Field[] fields = studentCls.getDeclaredFields();
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("select ");
+        for (Field field : fields) {
+            // 通过属性来获取注解
+            Column column = field.getAnnotation(Column.class);
+            String columnName = column.columnName();
+//            String type = column.columnType();
+            buffer.append(columnName);
+            buffer.append(",");
+        }
+        // select id,name,
+        buffer.deleteCharAt(buffer.length() - 1);
+        // select id,name
+        buffer.append(" from ");
+        buffer.append(tableName);
+        // select id,name from student
+        System.out.println(buffer);
+    }
+}

+ 5 - 0
spring-demo/src/main/java/com/sf/javase/anno/hello/Check.java

@@ -0,0 +1,5 @@
+package com.sf.javase.anno.hello;
+
+public @interface Check {
+    String value();
+}

+ 7 - 0
spring-demo/src/main/java/com/sf/javase/anno/hello/Test.java

@@ -0,0 +1,7 @@
+package com.sf.javase.anno.hello;
+
+//@Check(value = "zhangsan")
+@Check("zhangsan")
+@TestAnnotation(id = 0, msg = "hello")
+public class Test {
+}

+ 19 - 0
spring-demo/src/main/java/com/sf/javase/anno/hello/TestAnnotation.java

@@ -0,0 +1,19 @@
+package com.sf.javase.anno.hello;
+
+import java.lang.annotation.*;
+
+/**
+ * 元注解 描述注解的注解
+ * Retention 存活时间 对应三个阶段:源码、编译和运行
+ * RetentionPolicy 存活策略
+ *
+ * Target 注解使用的位置
+ * ElementType 元素类型 对应类、方法、属性、参数等等
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)  // 类或接口
+@Inherited
+public @interface TestAnnotation {
+    public int id() default -1;
+    public String msg() default "Hi";
+}

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/Main.java → spring-demo/src/main/java/com/sf/javase/base/Main.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 
 public class Main {
 

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/StaticInterview.java → spring-demo/src/main/java/com/sf/javase/base/StaticInterview.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 // 在有继承关系时 代码块、静态代码块和构造器的执行顺序  523164  524163  524613
 public class StaticInterview extends Base {
     {

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/TestCollection.java → spring-demo/src/main/java/com/sf/javase/base/TestCollection.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 
 import java.util.ArrayList;
 import java.util.Collections;

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/TestMath.java → spring-demo/src/main/java/com/sf/javase/base/TestMath.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 
 public class TestMath {
 

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/TestString.java → spring-demo/src/main/java/com/sf/javase/base/TestString.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 
 public class TestString {
 

+ 1 - 1
spring-demo/src/main/java/com/sf/javase/TestStringIntern.java → spring-demo/src/main/java/com/sf/javase/base/TestStringIntern.java

@@ -1,4 +1,4 @@
-package com.sf.javase;
+package com.sf.javase.base;
 
 public class TestStringIntern {
 

+ 11 - 0
spring-demo/src/main/java/com/sf/javase/computer/Computer.java

@@ -0,0 +1,11 @@
+package com.sf.javase.computer;
+
+/**
+ * 模拟笔记本设置操作系统的场景
+ * mac 设置的是苹果mac操作系统
+ * mi  设置的是windows操作系统
+ */
+public abstract class Computer {
+
+    public abstract void setOperationSystem();
+}

+ 32 - 0
spring-demo/src/main/java/com/sf/javase/computer/ComputerFactory.java

@@ -0,0 +1,32 @@
+package com.sf.javase.computer;
+
+/**
+ * 笔记本 加工工厂
+ */
+public class ComputerFactory {
+
+    // 生产笔记本  通过不同的品牌生产不同操作系统的笔记本
+    public static Computer makeComputer(String brand) {
+        Computer computer = null;
+        switch (brand) {
+            case "mac":
+                computer = new MacComputer();
+                break;
+            case "mi":
+                computer = new MiComputer();
+                break;
+            default:
+        }
+        return computer;
+    }
+
+    public static void main(String[] args) {
+        // 根据工厂来获取 具体的Computer
+        Computer computer = ComputerFactory.makeComputer("mi");
+        // 调用Computer设置操作系统方法
+        computer.setOperationSystem();
+
+        Computer macComputer = ComputerFactory.makeComputer("mac");
+        macComputer.setOperationSystem();
+    }
+}

+ 9 - 0
spring-demo/src/main/java/com/sf/javase/computer/IComputerFactory.java

@@ -0,0 +1,9 @@
+package com.sf.javase.computer;
+
+/**
+ * 将工厂也变为接口
+ */
+public interface IComputerFactory {
+    // 工厂是生产笔记本的
+    Computer makeComputer();
+}

+ 11 - 0
spring-demo/src/main/java/com/sf/javase/computer/MacComputer.java

@@ -0,0 +1,11 @@
+package com.sf.javase.computer;
+
+/**
+ * 苹果笔记本
+ */
+public class MacComputer extends Computer{
+    @Override
+    public void setOperationSystem() {
+        System.out.println("mac mac操作系统");
+    }
+}

+ 12 - 0
spring-demo/src/main/java/com/sf/javase/computer/MacComputerFactory.java

@@ -0,0 +1,12 @@
+package com.sf.javase.computer;
+
+/**
+ * 将工厂分离
+ * 苹果的笔记本工厂 只生产苹果
+ */
+public class MacComputerFactory implements IComputerFactory{
+    @Override
+    public Computer makeComputer() {
+        return new MacComputer();
+    }
+}

+ 11 - 0
spring-demo/src/main/java/com/sf/javase/computer/MiComputer.java

@@ -0,0 +1,11 @@
+package com.sf.javase.computer;
+
+/**
+ * 小米笔记本
+ */
+public class MiComputer extends Computer{
+    @Override
+    public void setOperationSystem() {
+        System.out.println("mi Windows操作系统");
+    }
+}

+ 8 - 0
spring-demo/src/main/java/com/sf/javase/computer/MiComputerFactory.java

@@ -0,0 +1,8 @@
+package com.sf.javase.computer;
+
+public class MiComputerFactory implements IComputerFactory{
+    @Override
+    public Computer makeComputer() {
+        return new MiComputer();
+    }
+}

+ 14 - 0
spring-demo/src/main/java/com/sf/javase/computer/Test.java

@@ -0,0 +1,14 @@
+package com.sf.javase.computer;
+
+public class Test {
+
+    public static void main(String[] args) {
+        // 生产Mac电脑  通过Mac工厂生产
+        IComputerFactory macFactory = new MacComputerFactory();
+        macFactory.makeComputer().setOperationSystem();
+
+        // 生产Mi电脑  通过Mi工厂生产
+        IComputerFactory miFactory = new MiComputerFactory();
+        miFactory.makeComputer().setOperationSystem();
+    }
+}

+ 2 - 4
spring-demo/src/main/java/com/sf/reflect/TestReflect.java → spring-demo/src/main/java/com/sf/javase/reflect/TestReflect.java

@@ -1,6 +1,4 @@
-package com.sf.reflect;
-
-import com.sf.javase.TestString;
+package com.sf.javase.reflect;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -11,7 +9,7 @@ public class TestReflect {
 
     public static void main(String[] args) throws Exception {
         Class testReflect = TestReflect.class;
-        Class forName = Class.forName("com.sf.reflect.TestReflect");
+        Class forName = Class.forName("com.sf.javase.reflect.TestReflect");
         // 获取类对象的方式有多种  但同一个类的对象只有一个
         // true or false
         System.out.println(testReflect == forName);

+ 1 - 1
spring-demo/src/main/java/com/sf/reflect/TestUser.java → spring-demo/src/main/java/com/sf/javase/reflect/TestUser.java

@@ -1,4 +1,4 @@
-package com.sf.reflect;
+package com.sf.javase.reflect;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;

+ 1 - 1
spring-demo/src/main/java/com/sf/reflect/TestUserByHCB.java → spring-demo/src/main/java/com/sf/javase/reflect/TestUserByHCB.java

@@ -1,4 +1,4 @@
-package com.sf.reflect;
+package com.sf.javase.reflect;
 
 import java.lang.reflect.Field;
 

+ 1 - 1
spring-demo/src/main/java/com/sf/reflect/User.java → spring-demo/src/main/java/com/sf/javase/reflect/User.java

@@ -1,4 +1,4 @@
-package com.sf.reflect;
+package com.sf.javase.reflect;
 
 public class User {
     private String name;

+ 1 - 1
spring-demo/src/main/java/com/sf/singleton/Singleton1.java → spring-demo/src/main/java/com/sf/javase/singleton/Singleton1.java

@@ -1,4 +1,4 @@
-package com.sf.singleton;
+package com.sf.javase.singleton;
 
 /**
  * 如果希望一个类 只创建一个对象

+ 1 - 1
spring-demo/src/main/java/com/sf/singleton/Singleton2.java → spring-demo/src/main/java/com/sf/javase/singleton/Singleton2.java

@@ -1,4 +1,4 @@
-package com.sf.singleton;
+package com.sf.javase.singleton;
 
 /**
  * 在使用时才创建对象

+ 1 - 1
spring-demo/src/main/java/com/sf/singleton/Singleton3.java → spring-demo/src/main/java/com/sf/javase/singleton/Singleton3.java

@@ -1,4 +1,4 @@
-package com.sf.singleton;
+package com.sf.javase.singleton;
 
 /**
  * 静态内部类

+ 1 - 1
spring-demo/src/main/java/com/sf/singleton/Singleton4.java → spring-demo/src/main/java/com/sf/javase/singleton/Singleton4.java

@@ -1,4 +1,4 @@
-package com.sf.singleton;
+package com.sf.javase.singleton;
 
 /**
  * 枚举

+ 1 - 1
spring-demo/src/main/java/com/sf/singleton/TestSingleton.java → spring-demo/src/main/java/com/sf/javase/singleton/TestSingleton.java

@@ -1,4 +1,4 @@
-package com.sf.singleton;
+package com.sf.javase.singleton;
 
 public class TestSingleton {
 

+ 1 - 1
spring-demo/src/main/java/com/sf/self/BeanDefined.java

@@ -8,7 +8,7 @@ import java.util.Map;
  */
 public class BeanDefined {
 
-    //    <bean id="user" class="com.sf.User">
+    //    <bean id="user" class="com.sf.helloworld.User">
 //    </bean>
     private String beanId;
     private String classPath;

+ 1 - 1
spring-demo/src/main/java/com/sf/self/BeanFactory.java

@@ -46,7 +46,7 @@ public class BeanFactory {
         for (BeanDefined beanDefined : beanDefinedList) {
             // 先通过传进来的id 找到对应的 classPath 再根据反射原理 来创建对象
             if (beanDefined.getBeanId().equals(beanId)) {
-                // <bean id="user" class="com.sf.User">
+                // <bean id="user" class="com.sf.helloworld.User">
                 // 通过反射来返回对象
                 String classPath = beanDefined.getClassPath();
                 // User.class

+ 5 - 7
spring-demo/src/main/java/com/sf/self/Test.java

@@ -1,19 +1,17 @@
 package com.sf.self;
 
-import com.sf.Role;
-import com.sf.User;
+import com.sf.helloworld.Role;
+import com.sf.helloworld.User;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 public class Test {
 
     public static void main(String[] args) throws Exception {
         BeanDefined beanDefined = new BeanDefined();
         beanDefined.setBeanId("user");
-        beanDefined.setClassPath("com.sf.User");
+        beanDefined.setClassPath("com.sf.helloworld.User");
         beanDefined.setScope("prototype");
 
 //        Map<String,String> propertyMap = new HashMap<>();
@@ -23,12 +21,12 @@ public class Test {
 
         BeanDefined roleBean = new BeanDefined();
         roleBean.setBeanId("role");
-        roleBean.setClassPath("com.sf.Role");
+        roleBean.setClassPath("com.sf.helloworld.Role");
 
         List<BeanDefined> beanDefinedList = new ArrayList<>();
         beanDefinedList.add(beanDefined);
         beanDefinedList.add(roleBean);
-        // 假设有一个xml文件   <bean id="user" class="com.sf.User"></bean>
+        // 假设有一个xml文件   <bean id="user" class="com.sf.helloworld.User"></bean>
 
         // 有了一个容器 加载了这个配置
 //        BeanFactory beanFactory = new BeanFactory();

+ 13 - 0
spring-demo/src/main/resources/spring-annotation.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        https://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context
+        https://www.springframework.org/schema/context/spring-context.xsd">
+
+<!-- 首先要引入新的命名空间 通过 component-scan 组件扫描的配置  来指定要扫描注解的包地址-->
+    <context:component-scan base-package="com.sf.anno">
+    </context:component-scan>
+</beans>

+ 16 - 0
spring-demo/src/main/resources/spring-auto.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        https://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="house" class="com.sf.auto.House" autowire="byType"></bean>
+    <bean id="chair" class="com.sf.auto.Chair" autowire="byName"></bean>
+    <bean id="teacher" class="com.sf.auto.Teacher">
+        <property name="name" value="jichao"/>
+    </bean>
+
+    <bean id="teacher1" class="com.sf.auto.Teacher">
+        <property name="name" value="zhangsan"/>
+    </bean>
+</beans>

+ 8 - 8
spring-demo/src/main/resources/spring-beans-new.xml

@@ -7,33 +7,33 @@
         http://www.springframework.org/schema/util
         https://www.springframework.org/schema/util/spring-util.xsd">
 
-    <bean id="user" class="com.sf.User">
+    <bean id="user" class="com.sf.helloworld.User">
         <constructor-arg name="name" value="zhaoliu"></constructor-arg>
         <constructor-arg name="desc" value="普通用户"></constructor-arg>
         <!--        如果我们想多个对象复用一个对象 可以使用ref进行关联-->
         <constructor-arg name="role" ref="role"></constructor-arg>
     </bean>
 
-    <bean id="user1" class="com.sf.User">
+    <bean id="user1" class="com.sf.helloworld.User">
         <constructor-arg name="name" value="zhangsan"></constructor-arg>
         <constructor-arg name="desc" value="普通用户"></constructor-arg>
         <!--        如果我们想多个对象复用一个对象 可以使用ref进行关联-->
         <constructor-arg name="role" ref="role"></constructor-arg>
     </bean>
 
-    <bean id="user2" class="com.sf.User">
+    <bean id="user2" class="com.sf.helloworld.User">
         <property name="name" value="zhangsan"></property>
         <property name="desc" value="普通用户"></property>
         <!--        如果我们想多个对象复用一个对象 可以使用ref进行关联-->
         <property name="role" ref="role"></property>
     </bean>
 
-    <bean id="role" class="com.sf.Role">
+    <bean id="role" class="com.sf.helloworld.Role">
         <constructor-arg name="name" value="guest"></constructor-arg>
     </bean>
 
     <!-- Role role1 = new Role();  role1.setDesc(String[]); -->
-    <bean id="role1" class="com.sf.Role">
+    <bean id="role1" class="com.sf.helloworld.Role">
 <!--        <constructor-arg name="name" value="guest"></constructor-arg>-->
         <property name="name" value="guest"></property>
         <property name="desc">
@@ -45,7 +45,7 @@
         </property>
     </bean>
 
-    <bean id="role2" class="com.sf.Role">
+    <bean id="role2" class="com.sf.helloworld.Role">
         <property name="name" value="guest"></property>
         <property name="userList">
             <list>
@@ -63,7 +63,7 @@
         </property>
     </bean>
 
-    <bean id="role3" class="com.sf.Role">
+    <bean id="role3" class="com.sf.helloworld.Role">
         <property name="name" value="guest"></property>
         <property name="userList">
             <list>
@@ -74,7 +74,7 @@
     </bean>
 
 
-    <bean id="role4" class="com.sf.Role">
+    <bean id="role4" class="com.sf.helloworld.Role">
         <property name="name" value="guest"></property>
         <property name="userList" ref="userListId"></property>
     </bean>

+ 7 - 7
spring-demo/src/main/resources/spring-beans.xml

@@ -6,21 +6,21 @@
 
     <!--    把名字 和 类路径配置进去-->
     <!-- User user = new User();   user.setName("zhangsan");   user.setDesc("普通用户");-->
-    <bean id="user" class="com.sf.User">
+    <bean id="user" class="com.sf.helloworld.User">
         <!--        如果要给属性赋值 使用property-->
         <property name="name" value="zhangsan"/>
         <property name="desc" value="普通用户"/>
     </bean>
 
     <!--  new User("lisi","普通用户")-->
-    <bean id="user2" class="com.sf.User">
+    <bean id="user2" class="com.sf.helloworld.User">
         <constructor-arg name="name" value="lisi"></constructor-arg>
         <constructor-arg name="desc" value="普通用户"></constructor-arg>
     </bean>
 
     <!-- String str = "\""; -->
     <!-- 如果在value中配置 小于号和大于号  -->
-    <bean id="user3" class="com.sf.User">
+    <bean id="user3" class="com.sf.helloworld.User">
         <property name="name" value="&lt;&gt;"/>
         <property name="desc">
             <value><![CDATA[a<>b]]></value>
@@ -28,24 +28,24 @@
     </bean>
 
 
-    <bean id="user1" class="com.sf.User">
+    <bean id="user1" class="com.sf.helloworld.User">
         <constructor-arg name="name" value="wangwu"></constructor-arg>
         <constructor-arg name="desc" value="普通用户"></constructor-arg>
         <constructor-arg name="role">
-            <bean class="com.sf.Role">
+            <bean class="com.sf.helloworld.Role">
                 <constructor-arg name="name" value="admin"/>
             </bean>
         </constructor-arg>
     </bean>
 
-    <bean id="user4" class="com.sf.User">
+    <bean id="user4" class="com.sf.helloworld.User">
         <constructor-arg name="name" value="zhaoliu"></constructor-arg>
         <constructor-arg name="desc" value="普通用户"></constructor-arg>
         <!--        如果我们想多个对象复用一个对象 可以使用ref进行关联-->
         <constructor-arg name="role" ref="role"></constructor-arg>
     </bean>
 
-    <bean id="role" class="com.sf.Role">
+    <bean id="role" class="com.sf.helloworld.Role">
         <constructor-arg name="name" value="guest"></constructor-arg>
     </bean>
 

+ 49 - 0
spring-demo/src/main/resources/spring-factory.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        https://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!-- 通过工厂方式来创建bean 此时class不是bean的类型 而是生产bean的工厂类-->
+    <!-- 我们在简单工厂模式中  通过配置工厂方法来获取具体的对象 -->
+    <!-- 此时工厂方法需要的参数  是通过构造器的配置传进去 -->
+    <!-- CarStaticFactory.getCar(3) -->
+    <bean id="bmwCar" class="com.sf.car.CarStaticFactory" factory-method="getCar">
+        <constructor-arg value="3"></constructor-arg>
+    </bean>
+
+    <bean id="audiCar" class="com.sf.car.CarStaticFactory" factory-method="getCar">
+        <constructor-arg value="2"></constructor-arg>
+    </bean>
+
+    <bean id="carFactory" class="com.sf.car.CarInstanceFactory">
+        <property name="map">
+            <map>
+                <entry key="4">
+                    <bean class="com.sf.car.Car">
+                        <property name="id" value="4"></property>
+                        <property name="name" value="BMW"></property>
+                        <property name="price" value="440000"></property>
+                    </bean>
+                </entry>
+                <entry key="5">
+                    <bean class="com.sf.car.Car">
+                        <property name="id" value="5"></property>
+                        <property name="name" value="XiaoMiSu7"></property>
+                        <property name="price" value="219000"></property>
+                    </bean>
+                </entry>
+            </map>
+        </property>
+    </bean>
+
+    <!-- CarStaticFactory.getCar(3) -->
+    <!-- car4 -> carFactory = new CarInstanceFactory();   carFactory.getCar(4); -->
+    <bean id="car4" factory-bean="carFactory" factory-method="getCar">
+        <constructor-arg value="4"></constructor-arg>
+    </bean>
+
+    <bean id="car5" factory-bean="carFactory" factory-method="getCar">
+        <constructor-arg value="5"></constructor-arg>
+    </bean>
+</beans>

+ 3 - 3
spring-demo/src/main/resources/spring-singleton.xml

@@ -5,12 +5,12 @@
         https://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <!--    默认是单例的-->
-<!--    <bean id="role" class="com.sf.Role" scope="singleton"></bean>-->
+<!--    <bean id="role" class="com.sf.helloworld.Role" scope="singleton"></bean>-->
     <!--   显示声明为多例的 prototype-->
-    <bean id="user" class="com.sf.User" scope="prototype"></bean>
+    <bean id="user" class="com.sf.helloworld.User" scope="prototype"></bean>
 
     <!--   bean的生命周期  创建 - 初始化 init-method - 可以使用 - 销毁 destroy-method -->
-    <bean id="auth" class="com.sf.Auth" init-method="init" destroy-method="destroy">
+    <bean id="auth" class="com.sf.helloworld.Auth" init-method="init" destroy-method="destroy">
         <property name="name" value="没权限"/>
     </bean>
 

+ 21 - 0
spring-demo/src/test/java/com/sf/TestAnno.java

@@ -0,0 +1,21 @@
+package com.sf;
+
+import com.sf.anno.House;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+/**
+ * @SpringJUnitConfig 是spring整合Junit的注解
+ */
+@SpringJUnitConfig(locations = "classpath:spring-annotation.xml")
+public class TestAnno {
+
+    @Autowired
+    private House house;
+
+    @Test
+    public void testAnno(){
+        System.out.println(house);
+    }
+}

+ 30 - 0
spring-demo/src/test/java/com/sf/TestAuto.java

@@ -0,0 +1,30 @@
+package com.sf;
+
+import com.sf.auto.Chair;
+import com.sf.auto.House;
+import com.sf.auto.Teacher;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class TestAuto {
+
+    @Test
+    public void test() {
+        ApplicationContext context = new ClassPathXmlApplicationContext("spring-auto.xml");
+
+        House house = context.getBean("house", House.class);
+        System.out.println(house);
+
+        // 只根据名字来获取对象 需要强转
+        Chair chair = (Chair) context.getBean("chair");
+        System.out.println(chair);
+
+//        Teacher teacher1 = (Teacher) context.getBean("teacher1");
+        // 使用前提 当配置文件中 此类型的对象只有一个时 可以这样使用
+//        Teacher teacher = context.getBean(Teacher.class);
+        // 可以使用 既根据名字又根据类型来获取对象
+        Teacher teacher = context.getBean("teacher", Teacher.class);
+        System.out.println(teacher);
+    }
+}

+ 21 - 0
spring-demo/src/test/java/com/sf/TestConfig.java

@@ -0,0 +1,21 @@
+package com.sf;
+
+import com.sf.anno.House;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+// 可以直接把配置文件 作为SpringJUnitConfig注解的参数传入
+@SpringJUnitConfig(SpringConfig.class)
+//@SpringJUnitConfig(locations = "classpath:spring-annotation.xml")
+public class TestConfig {
+
+    @Autowired
+    private House house;
+
+    @Test
+    public void test(){
+        System.out.println(house);
+    }
+
+}

+ 25 - 0
spring-demo/src/test/java/com/sf/TestFactory.java

@@ -0,0 +1,25 @@
+package com.sf;
+
+import com.sf.car.Car;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class TestFactory {
+
+    @Test
+    public void test(){
+        ApplicationContext context = new ClassPathXmlApplicationContext("spring-factory.xml");
+        Car bmw = (Car) context.getBean("bmwCar");
+        System.out.println(bmw);
+
+        Car audi = (Car) context.getBean("audiCar");
+        System.out.println(audi);
+
+        Car car4 = (Car) context.getBean("car4");
+        System.out.println(car4);
+
+        Car car5 = (Car) context.getBean("car5");
+        System.out.println(car5);
+    }
+}

+ 4 - 2
spring-demo/src/test/java/com/sf/TestSingleton.java

@@ -1,5 +1,7 @@
 package com.sf;
 
+import com.sf.helloworld.Role;
+import com.sf.helloworld.User;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -27,8 +29,8 @@ public class TestSingleton {
         // A是B的父类 或者 A是B的实现接口
         ApplicationContext context = new ClassPathXmlApplicationContext("spring-singleton.xml");
 //        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("spring-singleton.xml");
-        Auth auth = context.getBean(Auth.class);
-        System.out.println(auth);
+//        Auth auth = context.getBean(Auth.class);
+//        System.out.println(auth);
         // 关闭容器  因为多态的使用 强转成运行时类型 才能调用运行时类型的方法
         ((ClassPathXmlApplicationContext)context).close();
 //        context1.close();

+ 6 - 4
spring-demo/src/test/java/com/sf/TestUser.java

@@ -1,5 +1,7 @@
 package com.sf;
 
+import com.sf.helloworld.Role;
+import com.sf.helloworld.User;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -73,24 +75,24 @@ public class TestUser {
         // 在配置文件中生效
         // 声明一个对象 对应一个bean标签
 
-        //  <bean class="com.sf.Role">
+        //  <bean class="com.sf.helloworld.Role">
         //     <constructor-arg name="name" value="admin"/>
         //  </bean>
 
         // 包裹为构造器的参数
         // <constructor-arg name="name" value="wangwu"></constructor-arg>
         // <constructor-arg name="role">
-        //    <bean class="com.sf.Role">
+        //    <bean class="com.sf.helloworld.Role">
         //         <constructor-arg name="name" value="admin"/>
         //    </bean>
         //  </constructor-arg>
 
         // 变成调用全参构造器
-        //   <bean id="user1" class="com.sf.User">
+        //   <bean id="user1" class="com.sf.helloworld.User">
         //        <constructor-arg name="name" value="wangwu"></constructor-arg>
         //        <constructor-arg name="desc" value="普通用户"></constructor-arg>
         //        <constructor-arg name="role">
-        //            <bean class="com.sf.Role">
+        //            <bean class="com.sf.helloworld.Role">
         //                <constructor-arg name="name" value="admin"/>
         //            </bean>
         //        </constructor-arg>