You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
注解 @com.spring.learning.customizescanning.annotation.One 属性集合 :
属性 name : AnnotationAttributesTest
属性 value : AnnotationAttributesTest
注解 @com.spring.learning.customizescanning.annotation.Two 属性集合 :
属性 name : AnnotationAttributesTest
属性 value : Two
Q: Can @AliasFor be used with the value attributes for @component and @qualifier?
The short answer is: no.
The value attributes in @qualifier and in stereotype annotations (e.g., @component, @repository, @controller, and any custom stereotype annotations) cannot be influenced by @AliasFor. The reason is that the special handling of these value attributes was in place years before @AliasFor was invented. Consequently, due to backward compatibility issues it is simply not possible to use @AliasFor with such value attributes.
小马哥 @mercyblitz 你好,对于 Spring 注解属性覆盖与别名这一章节,个人觉得属性隐式覆盖例子使用
@Service
与@Component
value 属性覆盖有点不合适。测试过程中,发现隐式覆盖对于 value 属性不生效的,查看源码发现,其覆盖属性的排除了 value 属性。源码位置:
MergedAnnotationAttributesProcessor#postProcess
1613 行以下是我的测试例子。
输出结果:
从测试例子可以看到,隐式覆盖确实对 value 属性不生效。
所以个人觉得书中隐式覆盖的例子,会导致误解,认为隐式覆盖不会导致高层次同名属性值被低层次属性值覆盖(高层次属性值等于低层次注解属性值)。
或者说还是我对这个理解错误了?
The text was updated successfully, but these errors were encountered: