Announcement Announcement Module
No announcement yet.
Proxy created for beans that do not match the pointcut expression Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Proxy created for beans that do not match the pointcut expression


    I have following AOP configuration:

    		<aop:aspect id="operatorAuditAspect" ref="operatorAPIAuditor">
    			<aop:pointcut id="auditedOperation" expression="within(*) &amp;&amp; (@target( || @annotation(" />
    			<aop:after pointcut-ref="auditedOperation" method="doAudit" />
    This works OK, the advice is executed for all beans in package with @Audited annotation. However, it seems that ALL beans with types in package are now proxied, which results in exceptions when I want to inject beans with concrete types.


    No matching bean of type [] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

    Is this normal?

  • #2
    Which is correct and this has to do with your pointcut expression. It consists of a static part and part that is checked at runtime. The within is the static part, for this match proxies are created (basically everything in the package). The @target and @annotation are checked at runtime.

    I suggest a read of the AspectJ reference guide or the excellent AspectJ in Action (2nd edition).


    • #3
      Thanks, I got it working by changing @target to @within.