下午新建个maven工程,配置spring文件时,A.xml引用到了B.xml中配置的bean,不过报错,找不到bean,查找到如下网址:
http://stackoverflow.com/questions/7711750/how-to-reference-a-bean-of-another-xml-file-in-spring
解决方法有两种,可以import,可以直接添加所有的配置文件一起读取,
new ClassPathXmlApplicationContext(
new String[] { "classpath:META-INF/conf/spring/this-xml-conf.xml",
"classpath:META-INF/conf/spring/that-other-xml-conf.xml" } );
其实这里不用new String[]也行的,直接
new ClassPathXmlApplicationContext( "classpath:META-INF/conf/spring/this-xml-conf.xml",
"classpath:META-INF/conf/spring/that-other-xml-conf.xml" );
也是毫无压力滴