繁体   English   中英

我可以在接口上使用spring注释吗?

[英]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.

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