[問題] Spring aop開發是否大部分都使用AspectJ?
這是個滿攏統的問題....
是這樣的
我看大部分基於springAOP的開發都會使用AspectJ
可以在aop:pointcut後面接AspectJ表達式直接指定所有符合的方法當作pointcut
底下再用pointcut-ref與advice對應就可以達成aop
後來我發現好像還有幾個東西像是ProxyFactoryBean和interceptorNames等
不需要AspectJ就達成AOP的方法
可是這樣不就等於要自己額外加一個Bean了嗎?
一個pointcut又只能對應一個aspect
而且在實現getBean方法的時候也得選擇ProxyFactoryBean那個bean
這樣豈不是很麻煩麻而且又容易搞混
所以我想問
在開發上,先不管基於xml還是基於annoation
AspectJ的使用算是比自己創建一個ProxyFactory的Bean還常用嗎???
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.231.32.220
※ 文章網址: https://www.ptt.cc/bbs/java/M.1474448710.A.907.html
→
09/21 19:45, , 1F
09/21 19:45, 1F
→
09/21 19:45, , 2F
09/21 19:45, 2F
→
09/21 19:46, , 3F
09/21 19:46, 3F
類似下面這種用法
https://www.mkyong.com/spring3/spring-aop-aspectj-annotation-example/
基於annotation的AspectJ
我是聽在深圳駐點的SI說大陸很多有用spring的整合案子很多都是用AspectJ來
實作,我也是這樣所以去爬了相關文檔自己trytry看,發現比只用spring來實現
aop還要靈活 但我問身邊幾個有過spring經驗的沒幾個人知道這東西
※ 編輯: new122851 (61.231.32.220), 09/21/2016 22:44:52
推
09/21 23:09, , 4F
09/21 23:09, 4F
推樓上這篇文! 很詳細
至於台灣用spring aop還是aspectj哪個多呢? 我問到的是AspectJ很少甚至沒有
※ 編輯: new122851 (61.231.32.220), 09/21/2016 23:39:13
→
09/22 22:45, , 5F
09/22 22:45, 5F
→
09/22 22:45, , 6F
09/22 22:45, 6F
→
09/22 22:45, , 7F
09/22 22:45, 7F
→
09/22 22:45, , 8F
09/22 22:45, 8F
→
09/23 14:58, , 9F
09/23 14:58, 9F
感謝各位踴躍回復!
我後來發現對岸有一篇翻譯簡述了SpringAOP和AspectJ的區別
http://www.oschina.net/translate/comparative_analysis_between_spring_aop_and_aspectj
原來AspectJ也可以解決static和fina方法不能被覆蓋的問題
※ 編輯: new122851 (61.231.20.220), 09/23/2016 21:09:10
推
09/24 03:05, , 10F
09/24 03:05, 10F
→
09/24 03:06, , 11F
09/24 03:06, 11F
java 近期熱門文章
PTT數位生活區 即時熱門文章