简体   繁体   English

java注释的执行顺序

[英]the execution order of java annotations

I have some Java annotations of a method, how can I know the order of each annotation aspect? 我有一些方法的Java注释,我怎么知道每个注释方面的顺序? 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 . Cacheable来自SpringCache,而HystrixCommand来自第三方包,它们都是运行时注释,我需要CacheableHystrixCommand之前HystrixCommand ,但不能用@order标记它们。

So, how can I : 那么,我怎么能:

1、learn the order of annotation execution? 1,学习注释执行的顺序?

2、specify the order? 2,指定订单?

I have tried to search the problem, but if duplicated , please let me know. 我试图搜索问题,但如果重复,请告诉我。

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. 指示在特定连接点应用多个建议时执行缓存顾问程序的顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM