Spring autowired bean for @Aspect aspect is null

后端 未结 9 1063
离开以前
离开以前 2020-11-29 03:42

I have the following spring configuration:





        
9条回答
  •  醉梦人生
    2020-11-29 03:58

    This blog post explains it really well. Due to the fact that aspect singleton is created outside spring container you'd need to use factory-method=”aspectOf” that is only available after it is woven in by AspectJ ( not Spring AOP ) :

    Notice factory-method=”aspectOf” that tells Spring to use a real AspectJ ( not Spring AOP ) aspect to create this bean. So that after the aspect is woven in it has an “aspectOf” method.

    So that :

    No matching factory method found: factory method 'aspectOf()' - That would mean that the aspect was not woven by AspectJ weaver.

    From my experience with spring 3.1, if I don't use @Autowired but traditional setter for dependency injection, it gets injected and works as expected without aspectJ weaver. Although I'm encountering problems with the aspect being singleton... It results in 'perthis' instantiation model. .

提交回复
热议问题