Aspectj在WebSphere也 load time weaving

xiaoxiao2026-06-06  12

安装依赖包

把如下两个包

aspectjweaver.jar

aspectjrt.jar

放在如下目录

${WAS_INSTALL_ROOT}/java/jre/lib/ext

${WAS_INSTALL_ROOT}是Websphere按照目录(例如/usr/IBM/WebSphere/AppServer)

配置WebSphere

登录WebSphere管理控制台http://ip:9060/ibm/console

 

左边菜单 服务器 ==> 应用程序服务器 ==》 右边窗口点击你的服务器

服务器基础结构 ==》进程定义 ==》Java 虚拟机 

 

Java 虚拟机 输入框中 输入

-javaagent:${WAS_INSTALL_ROOT}/java/jre/lib/ext/aspectjweaver.jar

(例如-javaagent:/usr/IBM/WebSphere/AppServer/java/jre/lib/ext/aspectjweaver.jar

 

然后在Web应用中的jar文件META-INF/aop.xml或 classes/META-INF/aop.xml中配置要weaving的类

 

例如:

<?xml version="1.0"?> <!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> <aspectj> <weaver options="-showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler"> <exclude within="org.ofbiz.entity.OpensessionAspect"/> <exclude within="com.jeyo.workflow.JbpmContextAspect"/> <exclude within="(@org.aspectj.lang.annotation.Aspect *)"/> <exclude within="(!@com.achievo.framework.aspectj.annotation.WithAspectJWeave org..*) AND org..*"/> <include within="com.achievo..*"/> <include within="com.jeyo..*"/> <include within="org.ofbiz..*"/> <!-- <include within="org.ofbiz..*"/> <include within="org.ofbiz.entity.datasource.InitClcPlugin"/> <include within="org.ofbiz.base.util.LogToDB"/> <include within="org.ofbiz.content.webapp.control.*"/> --> <exclude within="java..*"/> <exclude within="org.aspectj..*"/> <exclude within="sun..*"/> <exclude within="com.ibm..*"/> <exclude within="org.eclipse..*"/> <exclude within="javax..*"/> <!-- <exclude within="(!@WithAspectJWeave org..*) AND org..*"/>--> <exclude within="org.hibernate..*"/> <exclude within="org.apache..*"/> <exclude within="org.quartz..*"/> </weaver> <aspects> <aspect name="com.achievo.framework.aspectj.AchievoAdviceOrderAspect"/> <aspect name="org.ofbiz.entity.OpensessionAspect"/> <aspect name="com.jeyo.workflow.JbpmContextAspect"/> <aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/> <aspect name="com.achievo.framework.transaction.aspectj.AchievoTransactionAspect"/> <!-- <aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect"/> --> </aspects> </aspectj>

 

 重启应用服务器

 web控制台 左边菜单 服务器 ==> 应用程序服务器 ==》 选中你的服务器

点击上面的重新启动

 

 

相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5049713.html

最新回复(0)