【发布时间】:2015-09-25 05:15:56
【问题描述】:
我声明了一个只有在“测试”配置文件处于活动状态时才应该运行的方面。 Spring 似乎不考虑 @Profile 注释,并在激活或不激活“测试”配置文件的情况下运行该方面。
下面是代码块:
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);
}
}
春季版:4.1.7.RELEASE
AspectJ 版:1.8.2
【问题讨论】:
-
你在哪里声明你的
MyAspectbean?你的配置是怎样的?
标签: java spring aspectj spring-annotations spring-profiles