Spring factory-method ="aspectOf".我们从RAD部署应用程序时无法正常工作 [英] Spring factory-method="aspectOf" is not working when we deploy the application from RAD
问题描述
我们正在使用带有Spring支持的AspectJ.我已经在我的ApplicationContext.xml中声明了我的方面,如下所示.
We are using AspectJ with Spring support. I have declared my aspect in my ApplicationContext.xml as below.
<context:annotation-config />
<context:spring-configured />
<context:component-scan base-package="com,com.util">
<context:exclude-filter type="regex" expression="com.xyz*.*" />
</context:component-scan>
<bean id="xyz" class="com.util.XyzAspect" factory-method="aspectOf"/>
方面类:
@Configurable
@Aspect
public class XyzAspect {
@Autowired
private XyzUtil xyzUtil;
@After("showPoint() ")
public void logUser( JoinPoint pjp ) throws Throwable {
Sysout("Some log Statement");
}
}
当我在命令提示符下执行Maven构建并将EAR手动部署在Websphere Application Server(7.0)中时,它工作正常.但是当我从RAD7.5(Rational Application Developer)管理控制台进行部署时,它提示找不到匹配的工厂方法:工厂方法'aspectOf'"问题.
It is working fine, when I am doing the Maven build from command prompt and deploy the EAR manually in the Websphere Application server (7.0). but when I am doing the deployment from RAD7.5(Rational Application Developer) admin console, it is giving 'No matching factory method found: factory method 'aspectOf'' issue.
有人可以完全解决这个问题吗?我也想从RAD运行该应用程序.预先感谢.
Can someone do the need full to get out of this issue. I want to run the application from RAD also. Thanks in advance.
推荐答案
AspectJ将方法aspectOf
编织到您的XyzAspect
中.我相信您使用编译时编织,因此Maven生成的EAR已正确修补"了类XyzAspect
的字节码,因此可以正常部署.如果使用IDE组装项目,则该类的字节码会丢失某些内容(它是Java源的精确表示,是不完整的").在编织期间,AspectJ将您的方面转换"为单例,即添加静态变量以保存唯一的实例,并添加方法(aspectOf
)以获取唯一的实例.看看此线程获得更多信息.
The method aspectOf
is weaved into your XyzAspect
by AspectJ. I believe you use compile-time weaving, so EAR produced by Maven has correctly "patched" bytecode for class XyzAspect
thus it deploys OK. If you assemble project with IDE, the bytecode of the class is missing certain things (it is exact representation of Java source an is "incomplete"). During the weaving AspectJ "converts" your aspect into singleton, that is adds static variable to hold the only instance and a method (aspectOf
) to get that only instance. Have a look at this thread to get more information.
这篇关于Spring factory-method ="aspectOf".我们从RAD部署应用程序时无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!