Spring factory-method=“aspectOf” is not working when we deploy the application from RAD

偶尔善良 提交于 2019-12-11 12:08:39

问题


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"/>

Aspect Class:

@Configurable
@Aspect
public class XyzAspect {

 @Autowired
 private XyzUtil xyzUtil;

 @After("showPoint() ")
 public void logUser( JoinPoint pjp ) throws Throwable {
   Sysout("Some log Statement");
 }
}

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.

Can someone do the need full to get out of this issue. I want to run the application from RAD also. Thanks in advance.


回答1:


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.



来源:https://stackoverflow.com/questions/29012515/spring-factory-method-aspectof-is-not-working-when-we-deploy-the-application-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!