「テスト」プロファイルがアクティブな場合にのみ実行する必要があるアスペクトを宣言しました。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);
}
}
Spring バージョン: 4.1.7.RELEASE
AspectJ バージョン: 1.8.2