I have aspect to do something but I need to be able to disable it i .properties file. I tried @ConditionalOnExpression
using solution here...
@Component
@Aspect
@ConditionalOnExpression("${enabled:false}")
public class OtherAspect {
@Pointcut("execution(* *(..))")
public void methodExecution() {
}
@Before("methodExecution()")
public void adviceMethod(JoinPoint joinPoint) {
System.out.println("OtherAspect 1");
if(true){
System.out.println("OtherAspect 2");
}
}
}
I tried @Value()...
@Component
@Aspect
public class OtherAspect {
@Value("${performance.log.enabled:true}")
private boolean enabled;
@Pointcut("execution(* *(..))")
public void methodExecution() {
}
@Before("methodExecution()")
public void adviceMethod(JoinPoint joinPoint) {
System.out.println("OtherAspect 1");
if(enabled){
System.out.println("OtherAspect 2");
}
}
}
I tried @Profile
@Component
@Aspect
@Profile("enabled")
public class OtherAspect {
@Pointcut("execution(* *(..))")
public void methodExecution() {
}
@Before("methodExecution()")
public void adviceMethod(JoinPoint joinPoint) {
System.out.println("OtherAspect 1");
}
}
Nothing worked. How can I disable at least execution of adviceMethod by application.properties or any other .properties file flag?