Qing преди 1 година
родител
ревизия
8961c7b34a

+ 7 - 0
spring-demo/.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+  </component>
+</project>

+ 6 - 0
spring-demo/.idea/google-java-format.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GoogleJavaFormatSettings">
+    <option name="enabled" value="false" />
+  </component>
+</project>

+ 14 - 0
spring-demo/.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 124 - 0
spring-demo/.idea/uiDesigner.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>

+ 6 - 0
spring-demo/.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

+ 87 - 43
spring-demo/.idea/workspace.xml

@@ -4,14 +4,28 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5aa6272e-23b4-48f4-9aaa-8caf45810aa0" name="Changes" comment="0410 reflect">
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/Role.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/User.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-beans-new.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-beans.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestUser.java" afterDir="false" />
+    <list default="true" id="5aa6272e-23b4-48f4-9aaa-8caf45810aa0" name="Changes" comment="0413 spring">
+      <change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/google-java-format.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/Auth.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanDefined.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/BeanFactory.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/Test.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/self/TestString.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton1.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton2.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton3.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/Singleton4.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/singleton/TestSingleton.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/spring-singleton.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/TestSingleton.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/Role.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/Role.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/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" />
@@ -26,8 +40,8 @@
   <component name="FileTemplateManagerImpl">
     <option name="RECENT_TEMPLATES">
       <list>
-        <option value="Spring Xml File" />
         <option value="Spring File" />
+        <option value="Spring Xml File" />
         <option value="Class" />
       </list>
     </option>
@@ -49,14 +63,19 @@
   "keyToString": {
     "Application.Main.executor": "Run",
     "Application.StaticInterview.executor": "Run",
+    "Application.Test.executor": "Run",
     "Application.TestCollection (1).executor": "Run",
     "Application.TestCollection (2).executor": "Run",
     "Application.TestCollection.executor": "Run",
     "Application.TestMath.executor": "Run",
     "Application.TestReflect.executor": "Run",
+    "Application.TestSingleton.executor": "Run",
+    "Application.TestString.executor": "Run",
     "Application.TestStringIntern.executor": "Run",
     "Application.TestUser.executor": "Run",
     "Application.TestUserByHCB.executor": "Run",
+    "JUnit.TestSingleton.test.executor": "Run",
+    "JUnit.TestSingleton.testLife.executor": "Run",
     "JUnit.TestUser.executor": "Run",
     "JUnit.TestUser.test.executor": "Run",
     "JUnit.TestUser.testNew.executor": "Run",
@@ -66,7 +85,7 @@
     "RunOnceActivity.ShowReadmeOnStart": "true",
     "git-widget-placeholder": "master",
     "kotlin-language-version-configured": "true",
-    "last_opened_file_path": "/Users/Qing/IdeaProjects/SiFu/VIP31/spring-demo/src/main/resources",
+    "last_opened_file_path": "/Users/Qing/IdeaProjects/SiFu/VIP31/spring-demo",
     "node.js.detected.package.eslint": "true",
     "node.js.detected.package.tslint": "true",
     "node.js.selected.package.eslint": "(autodetect)",
@@ -75,7 +94,7 @@
     "project.structure.last.edited": "Project",
     "project.structure.proportion": "0.1809181",
     "project.structure.side.proportion": "0.22295515",
-    "settings.editor.selected.configurable": "preferences.keymap",
+    "settings.editor.selected.configurable": "fileTemplates",
     "vue.rearranger.settings.migration": "true"
   }
 }]]></component>
@@ -84,13 +103,13 @@
       <recent name="$PROJECT_DIR$/src/main/resources" />
     </key>
   </component>
-  <component name="RunManager" selected="JUnit.TestUser.testNew">
-    <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.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.javase.*" />
+          <option name="PATTERN" value="com.sf.self.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
@@ -111,25 +130,12 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestUser" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
-      <option name="MAIN_CLASS_NAME" value="com.sf.reflect.TestUser" />
-      <module name="spring-demo" />
-      <extension name="coverage">
-        <pattern>
-          <option name="PATTERN" value="com.sf.reflect.*" />
-          <option name="ENABLED" value="true" />
-        </pattern>
-      </extension>
-      <method v="2">
-        <option name="Make" enabled="true" />
-      </method>
-    </configuration>
-    <configuration name="TestUserByHCB" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
-      <option name="MAIN_CLASS_NAME" value="com.sf.reflect.TestUserByHCB" />
+    <configuration name="TestSingleton" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
+      <option name="MAIN_CLASS_NAME" value="com.sf.singleton.TestSingleton" />
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.reflect.*" />
+          <option name="PATTERN" value="com.sf.singleton.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
@@ -137,7 +143,7 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="TestUser" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TestSingleton.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
@@ -146,13 +152,14 @@
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.TestUser" />
-      <option name="TEST_OBJECT" value="class" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestSingleton" />
+      <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.test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TestSingleton.testLife" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring-demo" />
       <extension name="coverage">
         <pattern>
@@ -161,8 +168,8 @@
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.TestUser" />
-      <option name="METHOD_NAME" value="test" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.TestSingleton" />
+      <option name="METHOD_NAME" value="testLife" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
@@ -186,11 +193,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.TestUser.test" />
-        <item itemvalue="JUnit.TestUser" />
-        <item itemvalue="Application.TestUser" />
-        <item itemvalue="Application.TestUserByHCB" />
       </list>
     </recent_temporary>
   </component>
@@ -205,7 +212,9 @@
       <workItem from="1712123973520" duration="8552000" />
       <workItem from="1712726738891" duration="779000" />
       <workItem from="1712732632988" duration="8215000" />
-      <workItem from="1712972174804" duration="13655000" />
+      <workItem from="1712972174804" duration="14892000" />
+      <workItem from="1713086100573" duration="122000" />
+      <workItem from="1713332000735" duration="11126000" />
     </task>
     <task id="LOCAL-00001" summary="0403 javaSE">
       <option name="closed" value="true" />
@@ -231,7 +240,15 @@
       <option name="project" value="LOCAL" />
       <updated>1712739686280</updated>
     </task>
-    <option name="localTasksCounter" value="4" />
+    <task id="LOCAL-00004" summary="0413 spring">
+      <option name="closed" value="true" />
+      <created>1712998863701</created>
+      <option name="number" value="00004" />
+      <option name="presentableId" value="LOCAL-00004" />
+      <option name="project" value="LOCAL" />
+      <updated>1712998863701</updated>
+    </task>
+    <option name="localTasksCounter" value="5" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -242,6 +259,7 @@
       <map>
         <entry key="105ff90c-1298-45f8-accf-4e56367b1b7b" value="TOOL_WINDOW" />
         <entry key="2836cf7e-9804-4f89-86fa-98fe8e7d455e" value="TOOL_WINDOW" />
+        <entry key="51df622a-cec1-408f-a310-c5c053f5c319" value="TOOL_WINDOW" />
       </map>
     </option>
     <option name="TAB_STATES">
@@ -296,6 +314,31 @@
             </State>
           </value>
         </entry>
+        <entry key="51df622a-cec1-408f-a310-c5c053f5c319">
+          <value>
+            <State>
+              <option name="FILTERS">
+                <map>
+                  <entry key="branch">
+                    <value>
+                      <list>
+                        <option value="HEAD" />
+                      </list>
+                    </value>
+                  </entry>
+                  <entry key="structure">
+                    <value>
+                      <list>
+                        <option value="dir:/Users/Qing/IdeaProjects/SiFu/VIP31/spring-demo" />
+                      </list>
+                    </value>
+                  </entry>
+                </map>
+              </option>
+              <option name="SHOW_ONLY_AFFECTED_CHANGES" value="true" />
+            </State>
+          </value>
+        </entry>
         <entry key="MAIN">
           <value>
             <State />
@@ -307,7 +350,8 @@
   <component name="VcsManagerConfiguration">
     <MESSAGE value="0403 javaSE" />
     <MESSAGE value="0410 reflect" />
-    <option name="LAST_COMMIT_MESSAGE" value="0410 reflect" />
+    <MESSAGE value="0413 spring" />
+    <option name="LAST_COMMIT_MESSAGE" value="0413 spring" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />

+ 38 - 0
spring-demo/src/main/java/com/sf/Auth.java

@@ -0,0 +1,38 @@
+package com.sf;
+
+public class Auth {
+
+    private String name;
+
+    public Auth() {
+        System.out.println("bean构造器");
+    }
+
+    public Auth(String name) {
+        this.name = name;
+    }
+
+    public void init(){
+        System.out.println("bean初始化");
+    }
+
+    public void destroy(){
+        System.out.println("bean销毁");
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        System.out.println("bean set属性");
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Auth{" +
+                "name='" + name + '\'' +
+                '}';
+    }
+}

+ 12 - 0
spring-demo/src/main/java/com/sf/Role.java

@@ -1,6 +1,7 @@
 package com.sf;
 
 import java.util.Arrays;
+import java.util.List;
 
 public class Role {
 
@@ -17,6 +18,16 @@ public class Role {
 
     private String[] desc;
 
+    private List<User> userList;
+
+    public List<User> getUserList() {
+        return userList;
+    }
+
+    public void setUserList(List<User> userList) {
+        this.userList = userList;
+    }
+
     public String getName() {
         return name;
     }
@@ -38,6 +49,7 @@ public class Role {
         return "Role{" +
                 "name='" + name + '\'' +
                 ", desc=" + Arrays.toString(desc) +
+                ", userList=" + userList +
                 '}';
     }
 }

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

@@ -0,0 +1,52 @@
+package com.sf.self;
+
+import java.util.Map;
+
+/**
+ * 是对配置文件中的bean的一种抽象
+ * 假如我们解析了配置文件 配置文件就是由多个bean对象构成的
+ */
+public class BeanDefined {
+
+    //    <bean id="user" class="com.sf.User">
+//    </bean>
+    private String beanId;
+    private String classPath;
+
+    // 默认的处理是单例的
+    private String scope = "singleton";
+
+    private Map<String, String> propertyMap;
+
+    public String getBeanId() {
+        return beanId;
+    }
+
+    public void setBeanId(String beanId) {
+        this.beanId = beanId;
+    }
+
+    public String getClassPath() {
+        return classPath;
+    }
+
+    public void setClassPath(String classPath) {
+        this.classPath = classPath;
+    }
+
+    public Map<String, String> getPropertyMap() {
+        return propertyMap;
+    }
+
+    public void setPropertyMap(Map<String, String> propertyMap) {
+        this.propertyMap = propertyMap;
+    }
+
+    public String getScope() {
+        return scope;
+    }
+
+    public void setScope(String scope) {
+        this.scope = scope;
+    }
+}

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

@@ -0,0 +1,85 @@
+package com.sf.self;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 处理bean对象的工厂类
+ */
+public class BeanFactory {
+
+    // 加载完配置文件后  得到的数据结构 有序的一个存放多个bean的list
+    private List<BeanDefined> beanDefinedList;
+
+    // 容器中要存放的是 beanId 通过bean的class创建的对象
+    private Map<String, Object> springIOC;
+
+    public BeanFactory() {
+    }
+
+    public BeanFactory(List<BeanDefined> beanDefinedList) throws Exception {
+        this.beanDefinedList = beanDefinedList;
+        springIOC = new HashMap<>();
+        // 先处理单例的对象
+        for (BeanDefined beanDefined : beanDefinedList) {
+            if (beanDefined.getScope().equals("singleton")) {
+                String classPath = beanDefined.getClassPath();
+                // User.class  Role.class
+                Class classObj = Class.forName(classPath);
+                Object instance = classObj.getDeclaredConstructor().newInstance();
+                springIOC.put(beanDefined.getBeanId(), instance);
+            }
+        }
+    }
+
+    // 如果是单例的对象 在加载list的时候先创建出来 在getBean时直接返回 以此保证唯一
+    // 如果是多例的对象 其实是在获取时再创建 每一次都是不同的对象
+    public Object getBean(String beanId) throws Exception {
+        Object instance = null;
+        if (springIOC.containsKey(beanId)) {
+            return springIOC.get(beanId);
+        }
+        // iter
+        for (BeanDefined beanDefined : beanDefinedList) {
+            // 先通过传进来的id 找到对应的 classPath 再根据反射原理 来创建对象
+            if (beanDefined.getBeanId().equals(beanId)) {
+                // <bean id="user" class="com.sf.User">
+                // 通过反射来返回对象
+                String classPath = beanDefined.getClassPath();
+                // User.class
+                Class classObj = Class.forName(classPath);
+                // new User()
+                // getDeclaredConstructor 得到默认的无参构造器
+                // newInstance 通过构造器来创建对象
+                instance = classObj.getDeclaredConstructor().newInstance();
+                // name -> setName()
+                // user.name = ""
+                Map<String, String> propertyMap = beanDefined.getPropertyMap();
+                if (propertyMap != null) {
+                    for (String key : propertyMap.keySet()) {
+                        // key="name" value="zhangsan"
+                        // setName()
+                        String value = propertyMap.get(key);
+                        Field field = classObj.getDeclaredField(key);
+                        // 打破封装
+                        field.setAccessible(true);
+                        field.set(instance, value);
+                    }
+                }
+                break;
+            }
+        }
+        return instance;
+    }
+
+    public List<BeanDefined> getBeanDefinedList() {
+        return beanDefinedList;
+    }
+
+    public void setBeanDefinedList(List<BeanDefined> beanDefinedList) {
+        this.beanDefinedList = beanDefinedList;
+    }
+}

+ 46 - 0
spring-demo/src/main/java/com/sf/self/Test.java

@@ -0,0 +1,46 @@
+package com.sf.self;
+
+import com.sf.Role;
+import com.sf.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.setScope("prototype");
+
+//        Map<String,String> propertyMap = new HashMap<>();
+//        propertyMap.put("name","zhangsan");
+//        propertyMap.put("desc","普通用户");
+//        beanDefined.setPropertyMap(propertyMap);
+
+        BeanDefined roleBean = new BeanDefined();
+        roleBean.setBeanId("role");
+        roleBean.setClassPath("com.sf.Role");
+
+        List<BeanDefined> beanDefinedList = new ArrayList<>();
+        beanDefinedList.add(beanDefined);
+        beanDefinedList.add(roleBean);
+        // 假设有一个xml文件   <bean id="user" class="com.sf.User"></bean>
+
+        // 有了一个容器 加载了这个配置
+//        BeanFactory beanFactory = new BeanFactory();
+//        beanFactory.setBeanDefinedList(beanDefinedList);
+        BeanFactory beanFactory = new BeanFactory(beanDefinedList);
+
+        User user = (User) beanFactory.getBean("user");
+        User user1 = (User) beanFactory.getBean("user");
+        System.out.println(user == user1);
+
+        Role role = (Role) beanFactory.getBean("role");
+        Role role1 = (Role) beanFactory.getBean("role");
+        System.out.println(role == role1);
+    }
+}

+ 16 - 0
spring-demo/src/main/java/com/sf/self/TestString.java

@@ -0,0 +1,16 @@
+package com.sf.self;
+
+public class TestString {
+
+    public static void main(String[] args) {
+        // "name" -> "setName"
+        String str = "name";
+        String upper = str.substring(0, 1).toUpperCase();
+        String other = str.substring(1);
+        System.out.println(upper + other);
+
+        // setname -> setName
+        // 还可以遍历全部方法  然后比较不区分大小写的情况下 能够匹配的方法名字
+        System.out.println(str.equalsIgnoreCase("Name"));
+    }
+}

+ 29 - 0
spring-demo/src/main/java/com/sf/singleton/Singleton1.java

@@ -0,0 +1,29 @@
+package com.sf.singleton;
+
+/**
+ * 如果希望一个类 只创建一个对象
+ * 创建且只创建一个
+ *
+ * 设计模式 单例模式
+ * 写代码过程中的范文 优秀示例
+ *
+ * Singleton 单个的
+ * 先把对象创建出来  饿汉式
+ */
+public class Singleton1 {
+
+    // 自己需要创建对象
+    private static Singleton1 instance = new Singleton1();
+
+    // 将构造器设置为私有的
+    private Singleton1(){
+    }
+
+    // 构建一个返回方法
+    // 如果方法是非静态的 方法需要被对象调用
+    // 因为此时外部是拿不到对象的  所以将方法设置为静态的
+    public static Singleton1 getInstance(){
+        return instance;
+    }
+
+}

+ 21 - 0
spring-demo/src/main/java/com/sf/singleton/Singleton2.java

@@ -0,0 +1,21 @@
+package com.sf.singleton;
+
+/**
+ * 在使用时才创建对象
+ * 懒汉式
+ */
+public class Singleton2 {
+
+    private static Singleton2 instance;
+    private Singleton2(){}
+
+    public static Singleton2 getInstance(){
+        // 可以在第一次调用时创建对象
+        // 如何区分是第一次  如果instance为null 再创建对象
+        if(instance == null){
+            instance = new Singleton2();
+        }
+        // 如果已经被创建过了  instance不为null 会返回上一次创建的对象
+        return instance;
+    }
+}

+ 19 - 0
spring-demo/src/main/java/com/sf/singleton/Singleton3.java

@@ -0,0 +1,19 @@
+package com.sf.singleton;
+
+/**
+ * 静态内部类
+ * 也遵循懒加载
+ * 同时 是线程安全的
+ */
+public class Singleton3 {
+
+    private Singleton3(){}
+
+    private static class SingletonInner{
+        private static final Singleton3 INSTANCE = new Singleton3();
+    }
+
+    public static Singleton3 getInstance(){
+        return SingletonInner.INSTANCE;
+    }
+}

+ 11 - 0
spring-demo/src/main/java/com/sf/singleton/Singleton4.java

@@ -0,0 +1,11 @@
+package com.sf.singleton;
+
+/**
+ * 枚举
+ * 是实现单例的最好方法
+ */
+public enum Singleton4 {
+    // final class Singleton4
+    INSTANCE;
+    //static final Singleton4 INSTANCE = new Singleton4();
+}

+ 25 - 0
spring-demo/src/main/java/com/sf/singleton/TestSingleton.java

@@ -0,0 +1,25 @@
+package com.sf.singleton;
+
+public class TestSingleton {
+
+    public static void main(String[] args) {
+        // 'Singleton1()' has private access in 'com.sf.singleton.Singleton1'
+//        new Singleton1();
+
+        Singleton1 instance = Singleton1.getInstance();
+        Singleton1 instance1 = Singleton1.getInstance();
+        System.out.println(instance == instance1);
+
+        Singleton2 instance2 = Singleton2.getInstance();
+        Singleton2 instance22 = Singleton2.getInstance();
+        System.out.println(instance2 == instance22);
+
+        Singleton3 instance3 = Singleton3.getInstance();
+        Singleton3 instance33 = Singleton3.getInstance();
+        System.out.println(instance3 == instance33);
+
+        Singleton4 instance4 = Singleton4.INSTANCE;
+        Singleton4 instance44 = Singleton4.INSTANCE;
+        System.out.println(instance4 == instance44);
+    }
+}

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

@@ -1,8 +1,11 @@
 <?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:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
-        https://www.springframework.org/schema/beans/spring-beans.xsd">
+        https://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        https://www.springframework.org/schema/util/spring-util.xsd">
 
     <bean id="user" class="com.sf.User">
         <constructor-arg name="name" value="zhaoliu"></constructor-arg>
@@ -18,6 +21,13 @@
         <constructor-arg name="role" ref="role"></constructor-arg>
     </bean>
 
+    <bean id="user2" class="com.sf.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">
         <constructor-arg name="name" value="guest"></constructor-arg>
     </bean>
@@ -33,4 +43,43 @@
         </property>
     </bean>
 
+    <bean id="role2" class="com.sf.Role">
+        <property name="name" value="guest"></property>
+        <property name="userList">
+            <list>
+                <ref bean="user1"/>
+                <ref bean="user2"/>
+            </list>
+<!--            <map>-->
+<!--                <entry>-->
+<!--                    <key>-->
+<!--                        <value></value>-->
+<!--                    </key>-->
+<!--                    <value></value>-->
+<!--                </entry>-->
+<!--            </map>-->
+        </property>
+    </bean>
+
+    <bean id="role3" class="com.sf.Role">
+        <property name="name" value="guest"></property>
+        <property name="userList">
+            <list>
+                <ref bean="user1"/>
+                <ref bean="user2"/>
+            </list>
+        </property>
+    </bean>
+
+
+    <bean id="role4" class="com.sf.Role">
+        <property name="name" value="guest"></property>
+        <property name="userList" ref="userList"></property>
+    </bean>
+
+    <util:list id="userList">
+        <ref bean="user1"/>
+        <ref bean="user2"/>
+    </util:list>
+
 </beans>

+ 14 - 0
spring-demo/src/main/resources/spring-singleton.xml

@@ -0,0 +1,14 @@
+<?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="role" class="com.sf.Role" scope="singleton"></bean>
+    <bean id="user" class="com.sf.User" scope="prototype"></bean>
+
+    <bean id="auth" class="com.sf.Auth" init-method="init" destroy-method="destroy">
+        <property name="name" value="没权限"/>
+    </bean>
+</beans>

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

@@ -0,0 +1,30 @@
+package com.sf;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class TestSingleton {
+
+    @Test
+    public void test() {
+        ApplicationContext context = new ClassPathXmlApplicationContext("spring-singleton.xml");
+        System.out.println("=======");
+        User user = (User) context.getBean("user");
+        User user1 = (User) context.getBean("user");
+        System.out.println(user == user1);
+
+        System.out.println("=======");
+        Role role = (Role) context.getBean("role");
+        Role role1 = (Role) context.getBean("role");
+        System.out.println(role == role1);
+    }
+
+    @Test
+    public void testLife() {
+        ApplicationContext context = new ClassPathXmlApplicationContext("spring-singleton.xml");
+        Auth auth = context.getBean(Auth.class);
+        System.out.println(auth);
+        ((ClassPathXmlApplicationContext)context).close();
+    }
+}

+ 9 - 0
spring-demo/src/test/java/com/sf/TestUser.java

@@ -45,11 +45,20 @@ public class TestUser {
         User user1 = (User) context.getBean("user1");
         System.out.println(user1);
 
+        User user2 = (User) context.getBean("user2");
+        System.out.println(user2);
+
         // role只被创建一次 比较不同user的role对象  是同一个
         System.out.println(user.getRole() == user1.getRole());
 
         Role role = (Role) context.getBean("role1");
         System.out.println(role);
+
+        Role role2 = (Role) context.getBean("role2");
+        System.out.println(role2);
+
+        Role role4 = (Role) context.getBean("role4");
+        System.out.println(role4);
     }
 
     @Test