### Spring提供了4種類型的AOP支持
* 基于代理的經典Spring AOP;
* 純POJO切面;
* @AspectJ注解驅動的切面;
* 注入式AspectJ切面(適用于Spring各版本)
說明:前三種都是Spring AOP實現的變體,Spring AOP構建在動態代理基礎之上,因此,Spring對AOP的支持局限于方法攔截
### SpringAOP開發方式
* XML配置方式
* 基于注解
通過配置文件的方式聲明如下(spring-aspectj-xml.xml)示例:
```
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!--<context:component-scan base-package=""-->
<!-- 定義目標對象 -->
<bean name="productDao" class="com.zejian.spring.springAop.dao.daoimp.ProductDaoImpl" />
<!-- 定義切面 -->
<bean name="myAspectXML" class="com.zejian.spring.springAop.AspectJ.MyAspectXML" />
<!-- 配置AOP 切面 -->
<aop:config>
<!-- 定義切點函數 -->
<aop:pointcut id="pointcut" expression="execution(* com.zejian.spring.springAop.dao.ProductDao.add(..))" />
<!-- 定義其他切點函數 -->
<aop:pointcut id="delPointcut" expression="execution(* com.zejian.spring.springAop.dao.ProductDao.delete(..))" />
<!-- 定義通知 order 定義優先級,值越小優先級越大-->
<aop:aspect ref="myAspectXML" order="0">
<!-- 定義通知
method 指定通知方法名,必須與MyAspectXML中的相同
pointcut 指定切點函數
-->
<aop:before method="before" pointcut-ref="pointcut" />
<!-- 后置通知 returning="returnVal" 定義返回值 必須與類中聲明的名稱一樣-->
<aop:after-returning method="afterReturn" pointcut-ref="pointcut" returning="returnVal" />
<!-- 環繞通知 -->
<aop:around method="around" pointcut-ref="pointcut" />
<!--異常通知 throwing="throwable" 指定異常通知錯誤信息變量,必須與類中聲明的名稱一樣-->
<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="throwable"/>
<!--
method : 通知的方法(最終通知)
pointcut-ref : 通知應用到的切點方法
-->
<aop:after method="after" pointcut-ref="pointcut"/>
</aop:aspect>
</aop:config>
</beans>
```
- 概述
- Spring的使命
- 環境變量
- spring架構
- Spring各版本特性
- Spring3.1新特性
- spring頂級項目
- spring基礎
- spring環境變量
- 依賴注入
- spring獲取bean方法
- BeanFactory vs FactoryBean
- JavaBean裝配
- XML顯式配置
- 基于JAVA配置
- 自動化裝配bean
- SpringBean的作用域
- Spring應用上下文實現
- springbean的生命周期
- 自定義Bean的創建與銷毀
- Spring容器啟動過程
- spring加載xsd文件的流程
- spring擴展接口
- Spring主要類功能說明
- spring事務管理
- 事務特性
- 數據庫事務隔離級別
- 事務隔離性問題
- spring事務隔離級別
- 事務傳播行為
- @Transactional
- 循環依賴
- 構造器注入
- 循環依賴原理
- spring循環依賴原理
- spring三級緩存
- Spring注解
- @Component
- @ComponentScan
- @Autowired
- @Import
- @ImportResource
- @Profile
- @Conditional
- @Qualifier
- @Scope
- @PropertySource
- @Value
- @EnableScheduling
- SpEL-Spring表達式
- Spring-AOP
- SpringAOP五種通知類型
- AOP術語
- SpringMVC
- MVC原理圖
- SpringMVC工作原理
- springboot
- @SpringCloudApplication
- springboot tomcat配置
- Spring Boot Starter POMs
- Spring Boot technical starters
- spring boot事件類型
- Springboot日志
- SpringCloud
- springcloud微服務解決方案
- 服務組件
- 注冊中心
- Eureka
- Spring Cloud Zookeeper
- nacos
- Hystrix熔斷原理
- Hystrix應用
- Spring Cloud Config
- 服務網關
- Zuul
- Spring Cloud Gateway
- 服務調用及負載
- Ribbon
- Feign&OpenFeign
- Turbine
- actuator
- springboot & springcloud
- springcloud vs dubbo
- 常見面試題
- BeanFactory和FactoryBean
- @Autowired/@Resource和@Inject的區別
- Singleton bean注入prototype bean
- 附錄