How to stop overiding a bean in Spring

前端 未结 2 396
失恋的感觉
失恋的感觉 2021-01-19 22:21

I noticed that if you define a bean with same id in two xml files, it would be overiden in the second file.

Say in file a.xml i have
       

        
2条回答
  •  感情败类
    2021-01-19 23:05

    Also:

      final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
      ctx.setAllowBeanDefinitionOverriding(false);
      ctx.setConfigLocations(shardContextImport);
      ctx.setParent(refreshedEvent.getApplicationContext());
      ctx.refresh();
    

提交回复
热议问题