跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • Spring 相关 总结从多个 xml 文件中加载 bean 的几种方法
未分類
22 9 月 2020

Spring 相关 总结从多个 xml 文件中加载 bean 的几种方法

Spring 相关 总结从多个 xml 文件中加载 bean 的几种方法

資深大佬 : gzk329 0

ApplicationContext ctx =     new ClassPathXmlApplicationContext("classpath:*conf-*.xml"); //或者 ApplicationContext ctx =     new ClassPathXmlApplicationContext("classpath*:a.xml,b.xml"); //或者 ApplicationContext ctx = new ClassPathXmlApplicationContext(     new String[] {"services.xml", "daos.xml"}, MessengerService.class); //或者 ApplicationContext ctx = new ClassPathXmlApplicationContext(     new String[] {"services.xml", "daos.xml"}); 

这个第三种是从 MesssengerService.class 的同文件夹下面找,那么这个第四种是什么意思呢?

大佬有話說 (2)

  • 主 資深大佬 : gzk329

    默认都是 相对路径
    那么第二种和第四种是没区别?
    第三种指了一个位置
    是这样吗

  • 資深大佬 : lxk11153

    – new ClassPathXmlApplicationContext( 这里不用带 classpath:前缀的
    – 1 2 的区别 https://blog.csdn.net/qq_30038111/article/details/82116559
    – 4 相对 classpath 下的”services.xml”, “daos.xml”

    —-
    自己看源码或者文档 https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#resources-app-ctx

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具