私は次のクラスを持っています:
@component
public class Car extends abstract Vehicle {
public Car() {
super(10);
}
}
public abstract class Vehicle {
@Autowired
private Validator em;
public Vehicle(int i) {
// init
}
public int getVehicle() {
}
}
次を使用してBeanを作成すると:
applicationContext.getAutowireCapableBeanFactory().createBean(..)
バリデータBeanを注入できないという例外で失敗します...
ただし、自動配線をセッター注入に変更すると、次のように機能します。
public abstract class Vehicle {
private Validator em;
public Vehicle(int i) {
// init
}
public int getVehicle() {
}
@Autowired
public set Em(Validator em) {
this.em = em;
}
}
誰かが私にこれを説明できますか? bena ライフサイクルの仕組みと関係がありますか?