Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the execution order of java annotations

I have some Java annotations of a method, how can I know the order of each annotation aspect? And how I can specify the order of them.

@MyAnnotaion
@Cacheable
@HystrixCommand
public void MYMethod() {}

Cacheable is from SpringCache and HystrixCommand is from third party package, and they are both runtime annotations, I need Cacheable to run before HystrixCommand, but cannot mark them with @order.

So, how can I :

1、learn the order of annotation execution?

2、specify the order?

I have tried to search the problem, but if duplicated , please let me know.

like image 639
FisherMartyn Avatar asked Nov 08 '22 06:11

FisherMartyn


1 Answers

you can mark order in enable caching , but this will be application wide setting

@EnableCaching(order=0) 

Indicate the ordering of the execution of the caching advisor when multiple advices are applied at a specific joinpoint.

like image 172
kuhajeyan Avatar answered Nov 14 '22 21:11

kuhajeyan