开发者社区 问答 正文

ClassPathXmlApplicationContext加载spring配置文件

通过ClassPathXmlApplicationContext加载spring配置文件 但是有两个配置文件中bean互相依赖 先加载哪个配置文件 都会出现BeanCreationException 求指点

展开
收起
a123456678 2016-03-17 09:59:27 3422 分享 版权
1 条回答
写回答
取消 提交回答
  • 可以考虑新建一个 c.xml,然后在 c.xml 里面 import a.xml 和 b.xml,这样的话,优先级交给 Spring 自己去管吧
    ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"a.xml","b.xml"});

    2019-07-17 19:04:34
    赞同 展开评论