Spring AOP not working, when the method is called internally within a bean

后端 未结 3 2100
轻奢々
轻奢々 2020-11-29 09:36

I have several Aspects coded in my application. All others works except for the following.

Service Interface

package com.enbiso.proj         


        
3条回答
  •  没有蜡笔的小新
    2020-11-29 10:15

    I guess the problem is the @args condition.

    Spring documentation states the following:

    @args - limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given type(s) 
    

    Therefore the parameter of @args has to be a type expression. So the correct pointcut expression is

    @AfterReturning(value = "execution(* com.enbiso.proj.estudo.system.service.impl.MessageServiceImpl.send(..)) && args(com.enbiso.proj.estudo.system.service.impl.Message")
    

    or simply

    @AfterReturning(value = "execution(* com.enbiso.proj.estudo.system.service.impl.MessageServiceImpl.send(com.enbiso.proj.estudo.system.service.impl.Message))")
    

    Please adjust the package of Message if it doesn't fit.

提交回复
热议问题