您的位置:首页 > 编程语言 > Java开发

spring加载配置文件的方式

2015-12-17 18:30 651 查看
ApplicationContext context = 
new
 
FileSystemXmlApplicationContext(
"WebRoot/WEB-INF/applicationContext.xml"
);


new
 
ClassPathXmlApplicationContext(
"applicationContext.xml"
);
//
从classpath中加载


new
 
FileSystemXmlApplicationContext(
"classpath:地址"
);
//
没有classpath表示当前目录


 

@RunWith
(SpringJUnit4ClassRunner.
class


@ContextConfiguration
({
"classpath:/ut/applicationContext.xml"
})



@org
.springframework.test.context.ContextConfiguration(locations={
"file:WebRoot/WEB-INF/applicationContext.xml"
})

@org
.springframework.test.context.ContextConfiguration(locations={
"classpath:applicationContext.xml"
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息