日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring 知识点详解

發布時間:2023/12/3 javascript 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring 知识点详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、Spring

1.1、簡介

  • Spring:春天------>給軟件行業帶來了春天!

  • 2002,首次推出了Spring框架的雛形: interface21框架!

  • Spring框架即以interface21框架為基礎,經過重新設計,并不斷豐富其內涵,于2004年3月24日,發布了1.0正式版。

  • Rod Johnson ,Spring Framework創始人,著名作者。很難想象Rod Johnson的學歷,真的讓好多人大吃一驚,他是悉尼大學的博士,然而他的專業不是計算機,而是音樂學。

  • spring理念:使現有的技術更加容易使用,本身是一個大雜燴,整合了現有的技術框架!

  • SSH : Struct2 + Spring + Hibernate !

  • SSM : SpringMvc + Spring + Mybatis!

官網: https:/lspring.io/projects/spring-framework#overview

官方下載地址: http://repo.spring.io/release/orglspringframework/spring

GitHub: https:/lgithub.comlspring-projects/spring-framework

1 <!-- https : //mvnrepository.com/artifact/org.springframework/spring-webmvc -->2<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</ artifactId> <version>5.2.O.RELEASE</version></ dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->8<dependency> <groupId>org.springframework</groupId> <artifactid>spring-jdbc</artifactId> <cversion>5.2.0.RELEASE</version></ dependency>

1.2、優點

  • Spring是一個開源的免費的框架(容器)!
  • Spring是一個輕量級的、非入侵式的框架!
  • 控制反轉(IOC),面向切面編程(AOP) !
  • 支持事務的處理,對框架整合的支持!

總結一句話: Spring就是一個輕量級的控制反轉(IOC))和面向切面編程(AOP)的框架!

2、IOC理論推導

  • UserDao 接口

  • UserDaoImpl 接口實現類

  • UserService 業務接口

  • UserServiceImpl 業務實現類

  • 在之前的業務中,用戶的需求可能會影響我們原來的代碼,我們需要根據用戶的需求去修改源代碼,如果程序代碼量十分大,修改一次的成本代價十分昂貴!

    我們使用一個Set接口實現,已經發生了革命性的變化!

    //利用set動態實現值的注入 public void setUserDao(UserDao userDao) {this.userDao = userDao; }
    • 之前,程序是主動創建對象,控制權在程序員手上!
    • 使用了Set注入后,程序不再具有主動性,二十變成了被動的接受對象

    這種思想,從本質上解決了問題,我們程序員不用再去管理對象的創建!系統的耦合性大大降低,可以更加專注在業務的實現上!這是IOC的原型!

    IOC本質

    **控制反轉loC(Inversion of Control),是一種設計思想,DI(依賴注入)是實現loC的一種方法,也有人認為DI只是loC的另一種說法。**沒有loC的程序中,我們使用面向對象編程,對象的創建與對象間的依賴關系完全硬編碼在程序中,對象的創建由程序自己控制,控制反轉后將對象的創建轉移給第三方,個人認為所謂控制反轉就是︰獲得依賴對象的方式反轉了。
    采用XML方式配置Bean的時候,Bean的定義信息是和實現分離的,而采用注解的方式可以把兩者合為一體,Bean的定義信息直接以注解的形式定義在實現類中,從而達到了零配置的目的。

    控制反轉是一種通過描述(XML或注解)并通過第三方去生產或獲取特定對象的方式。在Spring中實現控制反轉的是loC容器,其實現方法是依賴注入(Dependency Injection,Dl)。

    3、IOC創建對象的方式

    1.使用無參構造創建對象,默認!

    2.假設我們要使用有參構造創建對象

  • 下標賦值

    <!--第一種:下標賦值--> <bean id="user" class="com.nynu.qdy.pojo.User"><constructor-arg index="0" value="qdy學Java"/> </bean>
  • 通過類型創建

    <!--第一種:通過類型創建,不建議使用--> <bean id="user" class="com.nynu.qdy.pojo.User"><constructor-arg type="java.lang.String" value="qidayang"/> </bean>

    3.參數名

    <!--第三種方式:直接通過參數名創建--><bean id="user" class="com.nynu.qdy.pojo.User"><constructor-arg name="name" value="其打樣"/></bean>
  • **總結:**在配置文件加載的時候,容器中管理的對象就已經初始化了!

    4、Spring配置

    4.1、別名

    <!--如果添加了別名,我們也可以通過別名獲取這個對象--> <alias name="user" alias="userNew"/>

    4.2、Bean的配置

    <!--id:bean的唯一標識符,也就是我們學的對象名 class:bean所對應的全限定名:包名+類名 name:也是別名,而且name可以去多個別名--> <bean id="userT" class="com.nynu.qdy.pojo.UserT" name="userTNew,userTNew2 u3;u4"><constructor-arg name="name" value="xiahouxue"/> </bean>## 4.3import這個import,一般用于團隊開發使用,他可以將多個配置文件,導入合并為一個!假設,現在項目中有多個人開發,這三個人復制不同的類開發,不同的類需要注冊在不同的bean中,我們可以利用import將所有人的beans.xml合并為一個總的!- 張三- 李四- 王五- applicationContext.xml```xml<import resource="beans.xml"/><import resource="beans1.xml"/>

    使用的時候,直接使用總的配置就可以了!

    5、依賴注入(DI)

    5.1、構造器注入

    前面已經說過

    5.2、Set方式注入 【重點】

    • 依賴注入:Set注入!
      • 依賴:bean對象的創建依賴于容器!
      • 注入:bean對象中的所有屬性,由容器來注入!

    【環境搭建】

    ? 1.復雜類型

    ? 2.真實測試對象

    5.3、擴展方式注入

    實體類

    package com.nynu.qdy.pojo;public class Address {private String address;public String getAddress() {return address;}public void setAddress(String address) {this.address = address;}@Overridepublic String toString() {return "Address{" +"address='" + address + '\'' +'}';} } package com.nynu.qdy.pojo;import java.util.*;public class Student {private String name;private Address address;private String[] books;private List<String> hobbys;private Map<String, String> card;private Set<String> games;private String wife;private Properties info;public String getName() {return name;}public void setName(String name) {this.name = name;}public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}public String[] getBooks() {return books;}public void setBooks(String[] books) {this.books = books;}public List<String> getHobbys() {return hobbys;}public void setHobbys(List<String> hobbys) {this.hobbys = hobbys;}public Map<String, String> getCard() {return card;}public void setCard(Map<String, String> card) {this.card = card;}public Set<String> getGames() {return games;}public void setGames(Set<String> games) {this.games = games;}public String getWife() {return wife;}public void setWife(String wife) {this.wife = wife;}public Properties getInfo() {return info;}public void setInfo(Properties info) {this.info = info;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", address=" + address.toString() +", books=" + Arrays.toString(books) +", hobbys=" + hobbys +", card=" + card +", games=" + games +", wife='" + wife + '\'' +", info=" + info +'}';} }

    測試類

    import com.nynu.qdy.pojo.Student; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class MyTest {public static void main(String[] args) {ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");Student student = (Student) applicationContext.getBean("student");System.out.println(student.toString());}/*Student{name='qdy',address=Address{address='廈門'}, books=[紅樓夢, 西游記, 水滸傳],hobbys=[聽歌, 敲代碼, 看電影], card={身份證=1234567890, 銀行卡=1234345234, =},games=[lol, 王者, 吃雞],wife='null',info={學號=31, 性別=男, 年齡=19}}*/ }

    完善注入信息

    <?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/beanshttps://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="address" class="com.nynu.qdy.pojo.Address"><property name="address" value="廈門"/></bean><bean id="student" class="com.nynu.qdy.pojo.Student"><!--第一種:普通值注入--><property name="name" value="qdy"/><!--第二種:bean注入--><property name="address" ref="address"/><!--第三種:數組注入:ref--><property name="books" ><array><value>紅樓夢</value><value>西游記</value><value>水滸傳</value></array></property><!--List--><property name="hobbys"><list><value>聽歌</value><value>敲代碼</value><value>看電影</value></list></property><!--Map--><property name="card"><map><entry key="身份證" value="1234567890"/><entry key="銀行卡" value="1234345234"/><entry key="" value=""/></map></property><!--Set--><property name="games"><set><value>lol</value><value>王者</value><value>吃雞</value></set></property><!--null--><property name="wife" ><null/></property><!--Properties--><property name="info"><props ><prop key="性別"></prop><prop key="學號">31</prop><prop key="年齡">19</prop></props></property></bean> </beans>

    5.4、bean的作用域

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-RShuLO7Q-1620196766093)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210501170928751.png)]

    1.單例模式(Spring默認機制)

    1 <bean id="user2" class="com. kuang.pojo.user" c:age="18" c:name="狂神" scope="sing1eton" />

    2.原型模式:每次從容器中get的時候,都會產生一個新對象!

    1<bean id="accountservice" class="com.something.Defau1tAccountservice" scope="prototype" />

    3.其余的request、session、 application、這些個只能在web開發中使用到!

    6、Bean的自動裝配

    • 自動裝配是Spring滿足bean依賴的一種方式!
    • Spring會在上下文中自動尋找,并自動給bean裝配屬性!

    在Spring中有三中裝配方式

  • 在xml中顯示的配置
  • 在Java中顯示配置
  • 隱式的自動裝配bean 【重要】
  • 6.1、測試

    環境搭建:一個人有兩個寵物!

    6.2、ByName自動裝配

    <!--ByName:會自動在上下文中查找,和自己對象set方法后面的值對應的beanid--><bean id="people" class="com.nynu.qdy.pojo.People" autowire="byName"><property name="name" value="xq"/></bean>

    6.3、ByType自動裝配

    <bean id="dog" class="com.nynu.qdy.pojo.Dog"/><bean class="com.nynu.qdy.pojo.Cat"/><!--ByName:會自動在上下文中查找,和自己對象set方法后面的值對應的beanid--><!--ByType:會自動在上下文中查找,和自己對象屬性相同的bean, bean的id屬性可以省略--><bean id="people" class="com.nynu.qdy.pojo.People" autowire="byType"><property name="name" value="xq"/></bean>

    小結:

    • ByName的時候,需要保證所有的bean的id唯一,并且這個bean需要和自動注入的屬性的set方法的值一致!
    • ByType的時候,需要保證所有的bean的calss唯一,并且這個bean需要和自動注入的屬性的類型一致!

    6.4、使用注解自動裝配

    要使用注解須知:

  • 導入約束,context約束
  • == 配置注解的支持: context:annotation-config/
  • <?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/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsd"><context:annotation-config/></beans>

    @Autowired

    • 直接在屬性使用即可!也可以在set方法上使用!
    • 使用Autowired 我們可以不用編寫Set方法了,前提是自動裝配的屬性在IOC(Spring) 容器中,且符合名字ByName!

    科普:

    @Nullable 字段標記了這個注解,說明這個字段可以為null.

    7、使用注解開發

    在Spring 4 之后,要是用注解開發,必須要保證aop的包導入了!

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-kDTs6DJ4-1620196766095)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210503120036761.png)]

    使用注解需要導入context約束,增加注解的支持!

    <?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/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsd"><context:annotation-config/></beans>
  • bean
  • 屬性如何注解
  • //等價于 <bean id="user" class="com.nynu.qdy.pojo.User"/> @Component public class User {public String name;@Value("asdfas")public void setName(String name) {this.name = name;}
  • 衍生的注解

    ? @Component 有幾個衍生注解,我們在web開發中,會按照mvc三層架構分層!

    • dao 【@Repository】

    • service 【@Service】

    • controller 【@Controller】

      ? 這四個注解功能都是一樣的,都是將某個類注冊到Spring中,裝配Bean!

  • 自動裝配置

  • @Autowired : 自動裝配通過類型。名字如果Autowired不能唯一自動裝配上屬性,則需要通過@Qualifier(value="xxx")- @Nullable字段標記了這個注解,說明這個字段可以為null; @Resource:自動裝配通過名字。類型。
  • 作用域
  • //等價于 <bean id="user" class="com.nynu.qdy.pojo.User"/> @Component @Scope("prototype") public class User {public String name;@Value("asdfas")public void setName(String name) {this.name = name;}
  • 小結
  • xml與注解:

    • xml更加萬能,適合用于任何場合!維護簡單方便
    • 注解:不是自己的類使用不了,維護相對復雜!

    xml與注解最佳實踐:

    • xml用來管理bean
    • 注解只負責完成屬性的注入
    • 我們在使用的過程中,只需要注意一個問題:必須讓注解生效,就需要開啟注解的支持!
    <!--指定掃描包,這個包下的注解就會生效--><context:component-scan base-package="com.nynu.qdy"/><context:annotation-config/>

    8、使用Java的方式配置Spring

    我們現在要完全不使用Spring的xml配置了,全權交給Java來做!

    JavaConfig 是Spring的一個子項目,在Spring 4之后,它成為了一個核心功能!

    實體類:

    //這里這個注解的意思,就是說明這個類被Spring接管了,注冊到了Spring容器中 @Component public class User {public String name;public String getName() {return name;}@Value("其打樣") //屬性注入值public void setName(String name) {this.name = name;}@Overridepublic String toString() {return "User{" +"name='" + name + '\'' +'}';}

    配置文件:

    @Configuration //這個也會被Spring容器托管,注冊到容器中,因為他本來就是一個@Component //@Configuration 代表這是一個配置類,就和我們之前看的beans.xml是一樣的 @ComponentScan("com.nynu.qdy") @Import(UserConfig2.class) public class UserConfig {//注冊一個bean,就相當于之前寫的一個bean標簽//這個方法的名字就相當于bean標簽中的id屬性//這個方法的返回值就相當于bean標簽中的class屬性@Beanpublic User getUser() {//就是返回要注入到bean中的對象!return new User();}

    測試類:

    public class MyTest {public static void main(String[] args) {//如果完全使用了配置類方式去做,我們就只能通過AnnotationConfig 上:下文來獲取容器,通過配置類的cLass對象加載!ApplicationContext context = new AnnotationConfigApplicationContext(UserConfig.class);User user =(User) context.getBean("getUser");System.out.println(user.getName());} }

    這種純Java的配置文件,在SpringBoot中隨處可見!

    9、代理模式

    為什么要學習代理模式?因為就是SpringAOP的底層!【SpringAOP 和 SpringMVC】

    代理模式:

    • 靜態代理
    • 動態代理

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-bzJWtsGJ-1620196766097)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210504103610050.png)]

    9.1、靜態代理

    角色分析:

    • 抽象角色 ︰ 一般會使用接口或者抽象類來解決
    • 真實角色 ︰ 被代理的角色
    • 代理角色 ∶ 代理真實角色,代理真實角色后,我們一般會做一些附屬操作
    • 客戶 : 訪問代理對像的人!

    代碼步驟:

    1.接口

    /*** @author 平卉陌路*/ public interface Rent {//出租房屋public void rent(); }

    2.真實角色

    /*** @author 平卉陌路*/ public class Host implements Rent{@Overridepublic void rent() {System.out.println("房東要出租房子!");} }

    3.代理角色

    /*** @author 平卉陌路*/ public class Proxy implements Rent{private Host host;public Proxy() {}public Proxy(Host host) {this.host = host;}@Overridepublic void rent() {host.rent();seeHouse();signAgreement();free();}//看房public void seeHouse(){System.out.println("中介帶你看房!");}//簽合同public void signAgreement(){System.out.println("簽租賃合同");}//收中介費public void free(){System.out.println("收中介費");} }

    4.客戶端訪問代理角色

    /*** @author 平卉陌路*/ public class Client {public static void main(String[] args) {//房東要出租房子Host host = new Host();/*host.rent();*///代理,中介幫房東出租房子,但中介會有一些附屬操作Proxy proxy = new Proxy(host);//你不用面對房東,找中介租房即可!proxy.rent();} }

    代理模式的好處:

    • 可以使真實角色的操作更加純粹!不用去關注一些公共的業會公共也就就交給代理角色!
    • 實現了業務的分工!
    • 公共業務發生擴展的時候,方便集中管理!

    缺點:

    • 一個真實角色就會產生一個代理角色;代碼量會翻倍開發效率會變低

    9.2、加深理解

    聊聊橫向AOP開發:

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-l6mCq27F-1620196766099)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210504142911218.png)]

    9.3、動態代理

    • 動態代理和靜態代理角色一樣
    • 動態代理的代理類是動態生成的,不是我們直接寫好的!
    • 動態代理分為兩大類:基于接口的動態代理,基于類的動態代理
      • 基于接口—JDK動態代理 ----【我們在這里使用】
      • 基于類:cglib
      • java字節碼實現: javasist

    需要了解兩個類: Proxy:代理,InvocationHandler:調用處理程序

    動態代理的好處:

    • 可以使真實角色的操作更加純粹!不用去關注一些公共的業務
    • 公共也就就交給代理角色!實現了業務的分工!
    • 公共業務發生擴展的時候,方便集中管理!
    • 一個動態代理類代理的是一個接口,一般就是對應的一類業務。
    • 一個動態代理類可以代理多個類,只要是實現了同一個接口即可!

    10、AOP

    10.1、什么是AOP

    AOP (Aspect Oriented Programming)意為: 面向切面編程,通過預編譯方式和運行期動態代理實現程序功能的統一維護的一種技術。AOP是OOP的延續,是軟件開發中的一個熱點,也是Spring框架中的一個重要內容,是函數式編程的一種衍生范型。利用AOP可以對業務邏輯的各個部分進行隔離,從而使得業務邏輯各部分之間的耦合度降低,提高程序的可重用性,同時提高了開發的效率。

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-sG68kfs5-1620196766100)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210504213617773.png)]

    10.2 、Aop在Spring中的作用

    提供聲明式事務;允許用戶自定義切面。

    • 橫切關注點:跨越應用程序多個模塊的方法或功能。即是,與我們業務邏輯無關的,但是我們需要關注的部分,就是橫切關注點。如日志,安全,緩存,事務等等…
    • 切面(ASPECT)︰橫切關注點被模塊化的特殊對象。即,它是一個類。
    • 通知(Advice) :切面必須要完成的工作。即,它是類中的一個方法。
    • 目標(Target)︰被通知對象。
    • 代理(Proxy)∶向目標對象應用通知之后創建的對象。
    • 切入點(PointCut):切面通知執行的“地點"的定義。
    • 連接點(JointPoint):與切入點匹配的執行點。

    SpringAOP中,通過Advice定義橫切邏輯,Spring中支持5種類型的Advice:

    [外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-7Hdm9vfF-1620196766101)(C:\Users\17728\AppData\Roaming\Typora\typora-user-images\image-20210504215028586.png)]

    即Aop在不改變原有代碼的情況下,去增加新的功能.

    10.3、使用Spring實現Aop【重點】

    使用AOP織入,需要導入一個依賴包!

    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver --> <dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>1.9.5</version> </dependency>

    注冊bean:

    <!--注冊bean--><bean id="userService" class="com.nynu.qdy.service.UserServiceImpl"/><bean id="log" class="com.nynu.qdy.log.Log"/><bean id="afterLog" class="com.nynu.qdy.log.AfterLog"/>

    方式一 :使用Spring的接口 【主要是SpringAPI接口實現】

    <!--方式一:使用原生Spring API接口--> <!--配置aop:需要導入aop的約束--><aop:config><!--切入點 expression :表達式 execution:要執行的位置--><aop:pointcut id="pointcut" expression="execution(* com.nynu.qdy.service.UserServiceImpl.*(..))"/><!--執行環繞增加--><aop:advisor advice-ref="log" pointcut-ref="pointcut"/><aop:advisor advice-ref="afterLog" pointcut-ref="pointcut"/></aop:config>

    方式二 :自定義類實現AOP (XML)【主要是切面定義】

    <!--方式二:基于xml的聲明式AspectJ--><bean id="diy" class="com.nynu.qdy.diy.DiyPointCut"/><aop:config><!-- 自定義切面 ref:要引用的類--><aop:aspect ref="diy"><!--切入點--><aop:pointcut id="pointcut" expression="execution(* com.nynu.qdy.service.UserServiceImpl.*(..))"/><!--配置通知--><!--前置通知--><aop:before method="before" pointcut-ref="pointcut"/><!--后置通知--><aop:after method="after" pointcut-ref="pointcut"/><!--環繞通知--><aop:around method="around" pointcut-ref="pointcut"/><!--異常通知--><aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="throwable"/><!--最終通知--><aop:after-returning method="afterReturning" pointcut-ref="pointcut"/></aop:aspect></aop:config>

    方式三 :使用注解實現

    <!--方式三:基于注解的聲明式AspectJ--><bean id="annotationPointCut" class="com.nynu.qdy.diy.AnnotationPointCut"/><!--開啟注解支持 jdk(默認proxy-target-class="false") cglib(proxy-target-class="true")--><aop:aspectj-autoproxy proxy-target-class="true"/> ```xml ointcut" expression="execution(* com.nynu.qdy.service.UserServiceImpl.*(..))"/><!--配置通知--><!--前置通知--><aop:before method="before" pointcut-ref="pointcut"/><!--后置通知--><aop:after method="after" pointcut-ref="pointcut"/><!--環繞通知--><aop:around method="around" pointcut-ref="pointcut"/><!--異常通知--><aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="throwable"/><!--最終通知--><aop:after-returning method="afterReturning" pointcut-ref="pointcut"/></aop:aspect></aop:config>

    方式三 :使用注解實現

    <!--方式三:基于注解的聲明式AspectJ--><bean id="annotationPointCut" class="com.nynu.qdy.diy.AnnotationPointCut"/><!--開啟注解支持 jdk(默認proxy-target-class="false") cglib(proxy-target-class="true")--><aop:aspectj-autoproxy proxy-target-class="true"/>

    總結

    以上是生活随笔為你收集整理的Spring 知识点详解的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。