簡體   English   中英

在兩個 Web 應用程序之間共享 spring 方面 class

[英]sharing spring aspect class between two webapplications

我的應用程序包含兩個 web 應用程序和 EAR 級 jar 文件。 一個 web 應用程序(比方說 SPApp)是使用 Spring 構建的,另一個是使用 Struts (STApp) 構建的。 我想分享此處定義的 SPApp 的方面 class SystemArchitecture spring aop

6.2.3.3。 共享通用切入點定義

在 STApp 中。

我在 EAR 級別 jar 文件中添加了SystemArchitecture class 並從 SPApp 調用,但在訪問 STApp 時不執行。

於是我在 STApp 中移動了 class SystemArchitecture方面,令人驚訝的是它起作用了。 當我將SystemArchitecture放在 EAR 級別庫中時,我不確定出了什么問題。

請幫忙。

謝謝,哈努曼

Spring AOP 在 spring 之外無法工作。 AOP 的 Spring 實現基於動態代理,其中 spring bean 工廠將代理建議的類來注入您的切入點。 您所追求的是所謂的“加載時間編織”,其中 java 代理用於攔截 ClassLoader 並在加載建議的類時對其進行裝飾。 這是 AspectJ 功能,而不是 Spring AOP。 在此處閱讀更多信息: http://www.eclipse.org/aspectj/doc/released/devguide/ltw.html

Spring and AspectJ can play together as well, but it's limited to spring driven applications: http://static.springsource.org/spring/docs/3.0.0.RC2/spring-framework-reference/html/ch07s08.html

盡管如此,如果你想要“真正的”AOP,獨立於 Spring 那么你需要 go 加載時編織和 AspectJ。

編輯:可能誤讀了您的問題。 您說它僅在您將建議 class 放入應用程序本身時才在您的 struts 應用程序中有效。 從那我讀到你的 Struts 應用程序也是 Spring 驅動的。 在不知道您的配置的情況下很難給出答案。 具體來說,web.xml(兩者)、application.xml 和您的 Z2A2D5965E6ED9A3B13B24D 配置文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM