简体   繁体   English

@Inject 和 @ValueMapValue 注解的区别

[英]Difference between @Inject and @ValueMapValue annotations

While reading AEM documentation about using models , I couldn't figure out what is the difference between @Inject and @ValueMapValue annotation above the field.在阅读有关使用模型的AEM文档时,我无法弄清楚字段上方的@Inject@ValueMapValue注释之间有什么区别

I tried using both, and they both seems the same, so I must be missing something.我尝试使用两者,它们看起来都一样,所以我一定错过了一些东西。

They are not the same, @Inject is a general purpose annotation that makes the value available from a number of injectors.它们不一样,@ @Inject是一个通用注解,它使值可以从许多注入器中获得。

@ValueMapValue is an injector specific annotation that will specifically pick value from valuemap injector. @ValueMapValue是一个注入器特定的注解,它会专门从值映射注入器中选取值。 It is equivalent to @Inject @Source("valuemap")相当于@Inject @Source("valuemap")

When the injected value is available only from one injector, their behavior would be the same, however if the same property is provided by two different injectors (say script-binding and valuemap) they might inject different values.当注入的值只能从一个注入器获得时,它们的行为将是相同的,但是如果相同的属性由两个不同的注入器(例如脚本绑定和值映射)提供,它们可能会注入不同的值。 Read more here . 在这里阅读更多。

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

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