我有以下情况:
@Component
@Scope("prototype")
public abstract class AbstractA {
protected abstract String getData();
}
现在我将要求以动态方式创建此类的实例(使用匿名内部类)。如:
@Component
public class B {
public void some_method() {
//Obviously this is wrong, I want to be able to do this through Spring/beans.
new AbstractA() {
protected abstract String getData() {
return "abc";
}
}
}
}
在这种情况下,我如何才能获得原型bean的实例?