我正在使用Spring Boot,我想使用AspectJ.
以下作品(当然):
@Aspect
@Component
public class RequestMappingAspect {
@Before("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
public void advice(JoinPoint joinPoint) {
...
}
}
但是,如果@Component删除并@EnableAspectJAutoProxy添加,则以下操作无效.
@SpringBootApplication
@EnableSwagger2
@EnableAspectJAutoProxy
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
如何正确启用AspectJ自动代理?