Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource

后端 未结 1 2023
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 05:17

PROBLEM :

I am creating a pointcut for execution of a method in a class . This class is a controller class and denoted by annotation @Controller and hence no bean is

相关标签:
1条回答
  • 2020-12-03 05:47

    This is a limitation in Spring AOP. When you use AspectJ pointcuts to weave aspects into beans, Spring will use CGLIB to generate a subclass of the target, and invoke the aspects from that subclass.

    If the target class does not have a public default constructor, however, this will fail. CGLIB does have the ability to handle this, but this is all hidden behind the Spring AOP stuff and you can't change that behaviour.

    I can only suggest that you go back to using setter injection for your controller, rather than constructor injection. It's not ideal, I know, but I can't think of any other workaround.

    0 讨论(0)
提交回复
热议问题