asbtract class A {
    private String attr = "";
}
class B extends A {
    @Value("${xxx}")
    private String attr;
}
假如properties里面的xxx的值为“123”,配置了一个bean名叫a, a.attr的值是多少?“” 还是 “123”?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
自己new当然是""
给spring管理的才是"123"
我觉得应该是"", 因为成员变量是静态绑定,也就是说编译期就确定的。a在编译期的类型是class A。