java - Spring Profile doesn't work with Aspect annotation -
i declared aspect should run when "test" profile active. spring doesn't seem regard @profile annotation , runs aspect or without "test" profile being activated.
below code block:
import org.springframework.context.annotation.profile; import org.aspectj.lang.annotation.afterreturning; import org.aspectj.lang.annotation.aspect; import org.aspectj.lang.annotation.pointcut; @aspect @configurable @profile("test") public class myaspect { @autowired private myservice service; @pointcut("execution(private * method(..)) && args(table,..)") public void mypointcut(statsparametertable table) {} @afterreturning(pointcut = "mypointcut(table)") public void intercept(statsparametertable table) { myservice.dostuff(table); } }
spring version: 4.1.7.release
aspectj version: 1.8.2
to make @profile work, class should either @component or @configuration (not configurable). try annotating class @component.
Comments
Post a Comment