我必须从旧库导入基于xml的配置。我有一个使用@PostConstruct
方法的bean需要很长时间才能完成(从数据库中查找记录)。
是否可以使用@ImportResource
加载xml配置并以某种方式覆盖这一个bean definiotion?
我知道我可以在我的上下文中创建不同的bean但是spring仍会在旧的上执行@PostConstruct
。
此外,我无法更改旧版库中的源代码。
答案 0 :(得分:0)
如果你真的需要这样做,你可能想看看BeanFactoryPostProcessor钩子。见这里:https://docs.spring.io/spring/docs/4.3.x/spring-framework-reference/html/beans.html#beans-factory-extension-factory-postprocessors
但是,您将调整容器的行为方式,这应该谨慎进行。