spring项目打JAR包读取配置文件

Spring中使用classpath*加载配置文件,jar包中的配置文件不加载问题,解决方法:

在使用spring加载jar包中的配置文件时,不支持通配符,需要一个一个引入

new classPathXmlApplicationContext("classpath*:/conf/applicationContext.xml");

 

这里如果不用classpath,打成jar包后,调用会报错,找不到配置文件,在applicationContext.xml中引入要加载的配置

<import resource="beanconfigs/applicationContext_1.xml" /> 

<import resource="beanconfigs/applicationContext_2.xml" /> 

猜你喜欢

转载自kfcman.iteye.com/blog/2111807