我有一个基类,应该在派生类中设置属性。我必须使用注释。那可能怎么样? 我知道如何做到这一点与XML弹簧配置,但没有注释,因为我要写在属性?在派生类中设置基类的属性,使用弹簧注释
下面是一些示例代码:
public class Base {
// This property should be set
private String ultimateProperty;
// ....
}
public class Hi extends Base {
// ultimate property should be "Hi" in this class
// ...
}
public class Bye extends Base {
// ultimate property should be "Bye" in this class
// ...
}
这怎么可能与注解?
任何理由不只是调用的setter在你的构造函数中? –
'private String ultimateProperty'不是一个属性,它是一个字段。术语在这些问题中很重要。你的意思是一个领域,还是你的意思是一个属性(即与getter /和/或setter)? – skaffman