Browse Source

spring高级

guyanqing 1 year ago
parent
commit
829f140714
38 changed files with 700 additions and 50 deletions
  1. 124 0
      04maven/spring/.idea/uiDesigner.xml
  2. 49 48
      04maven/spring/.idea/workspace.xml
  3. 38 0
      04maven/spring/pom.xml
  4. 61 0
      04maven/spring/src/main/java/com/sf/aop/AopAspect.java
  5. 40 0
      04maven/spring/src/main/java/com/sf/aop/MathCalculator.java
  6. 34 0
      04maven/spring/src/main/java/com/sf/aop/MathCalculatorImpl.java
  7. 22 0
      04maven/spring/src/main/java/com/sf/dao/AccountDao.java
  8. 33 0
      04maven/spring/src/main/java/com/sf/dao/AccountDaoImpl.java
  9. 38 0
      04maven/spring/src/main/java/com/sf/proxy/ProxyUtils.java
  10. 22 0
      04maven/spring/src/main/java/com/sf/proxy/Secretary.java
  11. 12 0
      04maven/spring/src/main/java/com/sf/proxy/Sign.java
  12. 11 0
      04maven/spring/src/main/java/com/sf/proxy/TBoss.java
  13. 13 0
      04maven/spring/src/main/java/com/sf/service/AccountService.java
  14. 33 0
      04maven/spring/src/main/java/com/sf/service/AccountServiceImpl.java
  15. 36 0
      04maven/spring/src/main/resources/applicationContext.xml
  16. 15 0
      04maven/spring/src/main/resources/beanAop.xml
  17. 1 1
      04maven/spring/src/main/resources/db.properties
  18. 20 0
      04maven/spring/src/test/java/com/sf/aop/AopTest.java
  19. 27 0
      04maven/spring/src/test/java/com/sf/proxy/ProxyTest.java
  20. 19 0
      04maven/spring/src/test/java/com/sf/tx/TxTest.java
  21. 36 0
      04maven/spring/target/classes/applicationContext.xml
  22. 15 0
      04maven/spring/target/classes/beanAop.xml
  23. BIN
      04maven/spring/target/classes/com/sf/aop/AopAspect.class
  24. BIN
      04maven/spring/target/classes/com/sf/aop/MathCalculator.class
  25. BIN
      04maven/spring/target/classes/com/sf/aop/MathCalculatorImpl.class
  26. BIN
      04maven/spring/target/classes/com/sf/dao/AccountDao.class
  27. BIN
      04maven/spring/target/classes/com/sf/dao/AccountDaoImpl.class
  28. BIN
      04maven/spring/target/classes/com/sf/proxy/ProxyUtils$1.class
  29. BIN
      04maven/spring/target/classes/com/sf/proxy/ProxyUtils.class
  30. BIN
      04maven/spring/target/classes/com/sf/proxy/Secretary.class
  31. BIN
      04maven/spring/target/classes/com/sf/proxy/Sign.class
  32. BIN
      04maven/spring/target/classes/com/sf/proxy/TBoss.class
  33. BIN
      04maven/spring/target/classes/com/sf/service/AccountService.class
  34. BIN
      04maven/spring/target/classes/com/sf/service/AccountServiceImpl.class
  35. 1 1
      04maven/spring/target/classes/db.properties
  36. BIN
      04maven/spring/target/test-classes/com/sf/aop/AopTest.class
  37. BIN
      04maven/spring/target/test-classes/com/sf/proxy/ProxyTest.class
  38. BIN
      04maven/spring/target/test-classes/com/sf/tx/TxTest.class

+ 124 - 0
04maven/spring/.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>

+ 49 - 48
04maven/spring/.idea/workspace.xml

@@ -5,28 +5,27 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="8c3e0ed0-6141-4ee9-a284-3fa2d43ee5eb" name="Changes" comment="">
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/entity/Student.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/entity/User2.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/FactoryUser.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/InstanceFactory.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/factory/StaticFactory.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/processor/ABeanPostProcessor.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/bean5.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/bean6.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/bean7.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/db.properties" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/AppTest2.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/AppTest3.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/AppTest4.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/aop/AopAspect.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/aop/MathCalculator.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/aop/MathCalculatorImpl.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/dao/AccountDao.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/dao/AccountDaoImpl.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/proxy/ProxyUtils.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/proxy/Secretary.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/proxy/Sign.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/proxy/TBoss.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/service/AccountService.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/sf/service/AccountServiceImpl.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/applicationContext.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/beanAop.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/aop/AopTest.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/proxy/ProxyTest.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/test/java/com/sf/tx/TxTest.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/entity/Order.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/entity/Order.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/sf/entity/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/sf/entity/User.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/bean.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/bean.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/target/classes/bean.xml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/bean.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/target/classes/com/sf/entity/Order.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/sf/entity/Order.class" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/target/classes/com/sf/entity/User.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/sf/entity/User.class" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/target/test-classes/com/sf/AppTest.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/test-classes/com/sf/AppTest.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/db.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/db.properties" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/db.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/db.properties" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -36,6 +35,7 @@
   <component name="FileTemplateManagerImpl">
     <option name="RECENT_TEMPLATES">
       <list>
+        <option value="Interface" />
         <option value="spring-beans.schema" />
         <option value="Class" />
       </list>
@@ -60,6 +60,7 @@
     "RunOnceActivity.ShowReadmeOnStart": "true",
     "SHARE_PROJECT_CONFIGURATION_FILES": "true",
     "WebServerToolWindowFactoryState": "false",
+    "last_opened_file_path": "C:/Users/Lenovo/Desktop/spring1",
     "node.js.detected.package.eslint": "true",
     "node.js.detected.package.tslint": "true",
     "node.js.selected.package.eslint": "(autodetect)",
@@ -71,24 +72,24 @@
     "vue.rearranger.settings.migration": "true"
   }
 }]]></component>
-  <component name="RunManager" selected="JUnit.AppTest4.t1">
-    <configuration name="AppTest3.t1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+  <component name="RunManager" selected="JUnit.TxTest.t1">
+    <configuration name="AopTest.t1 (1)" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.aop.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
-      <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.AppTest3" />
+      <option name="PACKAGE_NAME" value="com.sf.aop" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.aop.AopTest" />
       <option name="METHOD_NAME" value="t1" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="AppTest3.t2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="AopTest.t1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring" />
       <extension name="coverage">
         <pattern>
@@ -97,55 +98,55 @@
         </pattern>
       </extension>
       <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.AppTest3" />
-      <option name="METHOD_NAME" value="t2" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.AopTest" />
+      <option name="METHOD_NAME" value="t1" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="AppTest3.t3" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="ProxyTest.t1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.proxy.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
-      <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.AppTest3" />
-      <option name="METHOD_NAME" value="t3" />
+      <option name="PACKAGE_NAME" value="com.sf.proxy" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.proxy.ProxyTest" />
+      <option name="METHOD_NAME" value="t1" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="AppTest3.t4" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="ProxyTest.t2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.proxy.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
-      <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.AppTest3" />
-      <option name="METHOD_NAME" value="t4" />
+      <option name="PACKAGE_NAME" value="com.sf.proxy" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.proxy.ProxyTest" />
+      <option name="METHOD_NAME" value="t2" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <configuration name="AppTest4.t1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+    <configuration name="TxTest.t1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
       <module name="spring" />
       <extension name="coverage">
         <pattern>
-          <option name="PATTERN" value="com.sf.*" />
+          <option name="PATTERN" value="com.sf.tx.*" />
           <option name="ENABLED" value="true" />
         </pattern>
       </extension>
-      <option name="PACKAGE_NAME" value="com.sf" />
-      <option name="MAIN_CLASS_NAME" value="com.sf.AppTest4" />
+      <option name="PACKAGE_NAME" value="com.sf.tx" />
+      <option name="MAIN_CLASS_NAME" value="com.sf.tx.TxTest" />
       <option name="METHOD_NAME" value="t1" />
       <option name="TEST_OBJECT" value="method" />
       <method v="2">
@@ -154,11 +155,11 @@
     </configuration>
     <recent_temporary>
       <list>
-        <item itemvalue="JUnit.AppTest4.t1" />
-        <item itemvalue="JUnit.AppTest3.t4" />
-        <item itemvalue="JUnit.AppTest3.t3" />
-        <item itemvalue="JUnit.AppTest3.t2" />
-        <item itemvalue="JUnit.AppTest3.t1" />
+        <item itemvalue="JUnit.TxTest.t1" />
+        <item itemvalue="JUnit.AopTest.t1 (1)" />
+        <item itemvalue="JUnit.ProxyTest.t2" />
+        <item itemvalue="JUnit.ProxyTest.t1" />
+        <item itemvalue="JUnit.AopTest.t1" />
       </list>
     </recent_temporary>
   </component>
@@ -170,7 +171,7 @@
       <option name="number" value="Default" />
       <option name="presentableId" value="Default" />
       <updated>1689993904831</updated>
-      <workItem from="1689993906819" duration="38359000" />
+      <workItem from="1689993906819" duration="63787000" />
     </task>
     <servers />
   </component>

+ 38 - 0
04maven/spring/pom.xml

@@ -45,6 +45,44 @@
       <artifactId>druid</artifactId>
       <version>1.1.10</version>
     </dependency>
+
+<!--    aop 依赖-->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aspects</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
+
+<!--    事务-->
+    <dependency>
+<!--      jdbc-->
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jdbc</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
+<!--    对象关系映射依赖-->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-orm</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
+<!--    解析。xml文件-->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-oxm</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
+<!--    事务的依赖-->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+      <version>4.3.27.RELEASE</version>
+    </dependency>
   </dependencies>
 
 

+ 61 - 0
04maven/spring/src/main/java/com/sf/aop/AopAspect.java

@@ -0,0 +1,61 @@
+package com.sf.aop;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.springframework.stereotype.Component;
+
+@Component
+@Aspect
+public class AopAspect {
+
+    @Pointcut("execution(* *.*(..))")
+    public void log(){
+
+    }
+
+//    前置通知
+    @Before("log()")
+    public void methodStart(JoinPoint joinPoint){
+//        获取方法的名称
+        String name = joinPoint.getSignature().getName();
+        //todo 插入日志的接口
+        System.out.println("方法名称"+name+"我是前置通知,我在方法执行前进行执行");
+    }
+
+//    返回通知
+    @AfterReturning(value = "execution(* *.*(..))",returning ="abc")
+    public void methodReturn(Object abc){
+        System.out.println("我是返回通知,我在方法返回时进行执行"+abc);
+
+    }
+
+//    异常通知
+    @AfterThrowing(value = "execution(* *.*(..))",throwing = "e")
+    public void methodThrow(Exception e){
+        System.out.println("我是异常通知,我在方法出现异常时进行执行");
+    }
+
+//    后置通知
+    @After("log()")
+    public void  methodAfter(){
+        System.out.println("我是后置通知,我在方法调用后进行执行");
+    }
+
+
+//    环绕通知
+    @Around("execution(public int com.sf.aop.MathCalculator.add(..))")
+    public Object methodAround(ProceedingJoinPoint joinPoint){
+        System.out.println("环绕--->前置通知");
+        Object proceed = new Object();
+        try {
+             proceed = joinPoint.proceed();
+            System.out.println("环绕-->返回通知");
+        } catch (Throwable e) {
+            System.out.println("环绕-->异常通知");
+        }finally {
+            System.out.println("环绕-->后置通知");
+        }
+        return proceed;
+    }
+}

+ 40 - 0
04maven/spring/src/main/java/com/sf/aop/MathCalculator.java

@@ -0,0 +1,40 @@
+package com.sf.aop;
+
+/**
+ * 加减乘除接口
+ */
+public interface MathCalculator {
+    /**
+     * 加法
+     * @param x
+     * @param y
+     * @return
+     */
+     int add(int x ,int y);
+
+    /**
+     * 减法
+     * @param x
+     * @param y
+     * @return
+     */
+     int sub(int x,int y);
+
+    /**
+     * 乘法
+     * @param x
+     * @param y
+     * @return
+     */
+     int mul(int x , int y);
+
+
+    /**
+     * 除法
+     * @param x
+     * @param y
+     * @return
+     */
+     int div(int x, int y);
+
+}

+ 34 - 0
04maven/spring/src/main/java/com/sf/aop/MathCalculatorImpl.java

@@ -0,0 +1,34 @@
+package com.sf.aop;
+
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+/**
+ * 加减乘除的实现类
+ */
+@Service
+public class MathCalculatorImpl implements MathCalculator{
+    @Override
+    public int add(int x, int y) {
+        int i = x + y;
+        return i;
+    }
+
+    @Override
+    public int sub(int x, int y) {
+        int i = x - y;
+        //添加个异常
+//        int q = 1/0;
+        return i;
+    }
+
+    @Override
+    public int mul(int x, int y) {
+        return x*y;
+    }
+
+    @Override
+    public int div(int x, int y) {
+        return x/y;
+    }
+}

+ 22 - 0
04maven/spring/src/main/java/com/sf/dao/AccountDao.java

@@ -0,0 +1,22 @@
+package com.sf.dao;
+
+public interface AccountDao {
+
+    /**
+     * 转入金额
+     * in:转入人--给谁转
+     * money:转入金额
+     */
+
+    void  inMoney(String in , Double money);
+
+
+    /**
+     * 转出金额
+     * out:从谁账号转出
+     * money:转出金额
+     */
+    void  outMoney(String out , Double money);
+
+
+}

+ 33 - 0
04maven/spring/src/main/java/com/sf/dao/AccountDaoImpl.java

@@ -0,0 +1,33 @@
+package com.sf.dao;
+
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.support.JdbcDaoSupport;
+
+/**
+ * 实现类
+ */
+public class AccountDaoImpl extends JdbcDaoSupport implements AccountDao{
+
+
+    /**
+     * 转入
+     * @param in
+     * @param money
+     */
+    @Override
+    public void inMoney(String in, Double money) {
+        String sql = "update account set money = money + ? where name = ?";
+        this.getJdbcTemplate().update(sql,money,in);
+    }
+
+    /**
+     * 转出
+     * @param out
+     * @param money
+     */
+    @Override
+    public void outMoney(String out, Double money) {
+        String sql = "update account set money = money - ? where name = ?";
+        this.getJdbcTemplate().update(sql,money,out);
+    }
+}

+ 38 - 0
04maven/spring/src/main/java/com/sf/proxy/ProxyUtils.java

@@ -0,0 +1,38 @@
+package com.sf.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * 动态代理
+ */
+public class ProxyUtils {
+
+    //目标代理对象
+    private Object target;  //相当于老板
+
+    public ProxyUtils(Object target) {
+        this.target = target;
+    }
+
+//    通过目标代理对象取获取代理对象
+
+    /**
+     * 第一个参数:目标代理对象的类的加载器
+     * 第二个参数:目标代理对象的接口
+     * 第三个参数:new InvocationHandler()  处理器
+     *
+     * Object:代理对象  --秘书
+     * @return
+     */
+
+    public Object getProxy(){
+        return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new InvocationHandler() {
+            @Override
+            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+                return method.invoke(target,args);
+            }
+        });
+    }
+}

+ 22 - 0
04maven/spring/src/main/java/com/sf/proxy/Secretary.java

@@ -0,0 +1,22 @@
+package com.sf.proxy;
+
+/**
+ * 秘书
+ */
+public class Secretary implements Sign{
+
+    private TBoss tBoss;
+
+    public Secretary(TBoss tBoss) {
+        this.tBoss = tBoss;
+    }
+
+
+    /**
+     * 秘书签字 --- 实际是老板签字
+     */
+    @Override
+    public void sign() {
+        tBoss.sign();
+    }
+}

+ 12 - 0
04maven/spring/src/main/java/com/sf/proxy/Sign.java

@@ -0,0 +1,12 @@
+package com.sf.proxy;
+
+/**
+ * 签字接口
+ */
+public interface Sign {
+
+    /**
+     * 签字方法
+     */
+   void sign();
+}

+ 11 - 0
04maven/spring/src/main/java/com/sf/proxy/TBoss.java

@@ -0,0 +1,11 @@
+package com.sf.proxy;
+
+/**
+ * 老板
+ */
+public class TBoss implements Sign{
+    @Override
+    public void sign() {
+        System.out.println("这是老板签的字...");
+    }
+}

+ 13 - 0
04maven/spring/src/main/java/com/sf/service/AccountService.java

@@ -0,0 +1,13 @@
+package com.sf.service;
+
+public interface AccountService {
+
+    /**
+     *
+     * @param in  转入账号
+     * @param out  转出账户
+     * @param money   流转金额
+     */
+
+    void  transfer(String in , String out ,Double money);
+}

+ 33 - 0
04maven/spring/src/main/java/com/sf/service/AccountServiceImpl.java

@@ -0,0 +1,33 @@
+package com.sf.service;
+
+import com.sf.dao.AccountDao;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class AccountServiceImpl implements AccountService{
+    private AccountDao accountDao;
+
+    public AccountServiceImpl() {
+    }
+    public AccountDao getAccountDao() {
+        return accountDao;
+    }
+    public void setAccountDao(AccountDao accountDao) {
+        this.accountDao = accountDao;
+    }
+
+    public AccountServiceImpl(AccountDao accountDao) {
+        this.accountDao = accountDao;
+    }
+    @Override
+    public void transfer(String in, String out, Double money) {
+//        转入
+        accountDao.inMoney(in,money);
+
+//        添加异常
+//        int y = 1/0;
+//        转出
+        accountDao.outMoney(out,money);
+
+    }
+}

+ 36 - 0
04maven/spring/src/main/resources/applicationContext.xml

@@ -0,0 +1,36 @@
+<?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" xmlns:tx="http://www.springframework.org/schema/tx"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
+
+<!--    外部资源导入-->
+    <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
+
+<!--    配置数据库-->
+    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
+        <property name="username" value="${jdbc_user}"></property>
+        <property name="password" value="${jdbc_password}"></property>
+        <property name="url" value="${jdbc_url}"></property>
+    </bean>
+
+
+<!--    注册dao-->
+    <bean id="accountDao" class="com.sf.dao.AccountDaoImpl">
+        <property name="dataSource" ref="dataSource"></property>
+    </bean>
+
+<!--    注册service-->
+
+    <bean id="accountService" class="com.sf.service.AccountServiceImpl">
+       <property name="accountDao" ref="accountDao"></property>
+    </bean>
+
+<!--    配置事务管理器-->
+    <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="dataSource"></property>
+    </bean>
+
+<!--    开启基于注解的事务管理-->
+    <tx:annotation-driven transaction-manager="dataSourceTransactionManager"></tx:annotation-driven>
+</beans>

+ 15 - 0
04maven/spring/src/main/resources/beanAop.xml

@@ -0,0 +1,15 @@
+<?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"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
+
+
+<!--    配置需要实例化扫描的包-->
+    <context:component-scan base-package="com"></context:component-scan>
+
+<!--    开启aop的注解功能-->
+    <aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
+
+</beans>

+ 1 - 1
04maven/spring/src/main/resources/db.properties

@@ -1,3 +1,3 @@
 jdbc_user=root
 jdbc_password=root
-jdbc_url=jdbc:mysql://127.0.0.1:3306/mybatis2
+jdbc_url=jdbc:mysql://127.0.0.1:3306/spring2?characterEncoding=utf-8&useUnicode=true

+ 20 - 0
04maven/spring/src/test/java/com/sf/aop/AopTest.java

@@ -0,0 +1,20 @@
+package com.sf.aop;
+
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AopTest {
+    /**
+     * 测试aop
+     */
+    @Test
+    public void t1(){
+        ApplicationContext ioc = new ClassPathXmlApplicationContext("beanAop.xml");
+        MathCalculator mathCalculator = ioc.getBean(MathCalculator.class);
+        //我是前置通知,我在方法执行前进行执行
+        int add = mathCalculator.add(2, 3);
+        //我是后置通知,我在方法调用后进行执行
+        System.out.println("打印方法返回值"+add);
+    }
+}

+ 27 - 0
04maven/spring/src/test/java/com/sf/proxy/ProxyTest.java

@@ -0,0 +1,27 @@
+package com.sf.proxy;
+
+import org.junit.Test;
+
+public class ProxyTest {
+    /**
+     * 测试代理
+     */
+    @Test
+    public void t1(){
+      Sign sign =  new Secretary(new TBoss());
+//      签字
+      sign.sign();
+    }
+
+    /**
+     * 测试动态代理  --proxyUtils
+     */
+    @Test
+    public void t2(){
+//        通过目标代理对象 去生成代理对象
+        ProxyUtils proxyUtils = new ProxyUtils(new TBoss());
+       Sign sign = (Sign) proxyUtils.getProxy();
+//      调用签字方法
+       sign.sign();
+    }
+}

+ 19 - 0
04maven/spring/src/test/java/com/sf/tx/TxTest.java

@@ -0,0 +1,19 @@
+package com.sf.tx;
+
+import com.sf.service.AccountService;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * 事务的测试
+ */
+public class TxTest {
+  @Test
+    public void t1(){
+      ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
+      AccountService accountService = (AccountService) ioc.getBean("accountService");
+      accountService.transfer("li4","z3",500.00);
+  }
+
+}

+ 36 - 0
04maven/spring/target/classes/applicationContext.xml

@@ -0,0 +1,36 @@
+<?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" xmlns:tx="http://www.springframework.org/schema/tx"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
+
+<!--    外部资源导入-->
+    <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
+
+<!--    配置数据库-->
+    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
+        <property name="username" value="${jdbc_user}"></property>
+        <property name="password" value="${jdbc_password}"></property>
+        <property name="url" value="${jdbc_url}"></property>
+    </bean>
+
+
+<!--    注册dao-->
+    <bean id="accountDao" class="com.sf.dao.AccountDaoImpl">
+        <property name="dataSource" ref="dataSource"></property>
+    </bean>
+
+<!--    注册service-->
+
+    <bean id="accountService" class="com.sf.service.AccountServiceImpl">
+       <property name="accountDao" ref="accountDao"></property>
+    </bean>
+
+<!--    配置事务管理器-->
+    <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="dataSource"></property>
+    </bean>
+
+<!--    开启基于注解的事务管理-->
+    <tx:annotation-driven transaction-manager="dataSourceTransactionManager"></tx:annotation-driven>
+</beans>

+ 15 - 0
04maven/spring/target/classes/beanAop.xml

@@ -0,0 +1,15 @@
+<?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"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
+
+
+<!--    配置需要实例化扫描的包-->
+    <context:component-scan base-package="com"></context:component-scan>
+
+<!--    开启aop的注解功能-->
+    <aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
+
+</beans>

BIN
04maven/spring/target/classes/com/sf/aop/AopAspect.class


BIN
04maven/spring/target/classes/com/sf/aop/MathCalculator.class


BIN
04maven/spring/target/classes/com/sf/aop/MathCalculatorImpl.class


BIN
04maven/spring/target/classes/com/sf/dao/AccountDao.class


BIN
04maven/spring/target/classes/com/sf/dao/AccountDaoImpl.class


BIN
04maven/spring/target/classes/com/sf/proxy/ProxyUtils$1.class


BIN
04maven/spring/target/classes/com/sf/proxy/ProxyUtils.class


BIN
04maven/spring/target/classes/com/sf/proxy/Secretary.class


BIN
04maven/spring/target/classes/com/sf/proxy/Sign.class


BIN
04maven/spring/target/classes/com/sf/proxy/TBoss.class


BIN
04maven/spring/target/classes/com/sf/service/AccountService.class


BIN
04maven/spring/target/classes/com/sf/service/AccountServiceImpl.class


+ 1 - 1
04maven/spring/target/classes/db.properties

@@ -1,3 +1,3 @@
 jdbc_user=root
 jdbc_password=root
-jdbc_url=jdbc:mysql://127.0.0.1:3306/mybatis2
+jdbc_url=jdbc:mysql://127.0.0.1:3306/spring2?characterEncoding=utf-8&useUnicode=true

BIN
04maven/spring/target/test-classes/com/sf/aop/AopTest.class


BIN
04maven/spring/target/test-classes/com/sf/proxy/ProxyTest.class


BIN
04maven/spring/target/test-classes/com/sf/tx/TxTest.class