我想要这样的东西:
@Servise
public class BeanAFactory implements FactoryBean<BeanA>{
@Autowired <…>;
@Override
public BeanA getObject() throws Exception {
return new BeanAImpl();
}
@Override
public Class<BeanA> getObjectType() {
return BeanA.class;
}
@Override
public boolean isSingleton() {
return false;
}
private class BeanAImpl implements BeanA {
<…>
}
}
并自动装配BeanAFactory.getObject()
on的结果BeanA
:ctx.getBean(BeanA.class)
应该返回BeanAFactory.getObject()
. 可能吗?