[英]Can I use the Spring Security @PreAuthorize on my own annotations?
[英]Can I use spring annotations on interfaces?
我在努力理解Spring框架。 我曾经使用过Java EE。
在编写接口和实现时,可以在接口上使用注释吗?
@Repository // Can I do this?
interface MyRepository {
}
@Repository // Can I omit this?
class MyRepositoryImpl implements MyRepository {
}
@Service
呢? 一样吗
根据注释定义,我们可以使用注释接口。 当我们定义接口时,如果该接口定义为@Target({ java.lang.annotation.ElementType.TYPE })
,
然后TYPE
可以是Class, interface (including annotation type), or enum declaration TYPE
根据javadoc的 Class, interface (including annotation type), or enum declaration TYPE
。
,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.