在接口上注解? [英] Annotations on Interfaces?
本文介绍了在接口上注解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能为我的生活出了能够在注释Java接口用例。
I can't for the life of me figure out a use case for being able to annotate interfaces in Java.
也许有人比我聪明可以给我一个例子吗?
Maybe someone smarter than I am could give me an example?
推荐答案
我用它在Spring注释,其中注释应适用于所有子类的接口。例如,假设你有一个服务界面,你可能有多个接口实现,但你想,无论注解的安全注解申请。在这种情况下,最有意义来注释接口
I've used it in Spring to annotate interfaces where the annotation should apply to all subclasses. For example, say you have a Service interface and you might have multiple implementations of the interface but you want a security annotation to apply regardless of the annotation. In that case, it makes the most sense to annotate the interface.
这篇关于在接口上注解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文