zoukankan      html  css  js  c++  java
  • Junit手动/自动加载spring配置文件

    分配置文件在classpath下和web-inf下两种情况的加载: 

    ApplicationContext context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/applicationContext.xml"); 
    new ClassPathXmlApplicationContext("applicationContext.xml");// 从classpath中加载 
    new FileSystemXmlApplicationContext("classpath:地址");// 没有classpath表示当前目录 
    

      




    注解加载 

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

      

    @RunWith(SpringJUnit4ClassRunner.class)  
    @ContextConfiguration({"classpath:/ut/applicationContext.xml"}) 
    public class ScanDecisionFileTest {
    
    	@Before
    	public void setUp() throws Exception {
    	}
    
    	@After
    	public void tearDown() throws Exception {
    	}
    
    	@Test
    	public void testRun() {
    		//fail("Not yet implemented");
    	}
    
    }
    

      

  • 相关阅读:
    关于*和&的数组操作运算对比(一维数组)
    GCC内联汇编
    输出10进制、16进制
    异常退出时的出栈
    字典
    List简单增删改查
    数组的增删改查
    Excel的简单导入导出
    文件流
    Lambda 的简单入门
  • 原文地址:https://www.cnblogs.com/jifeng/p/4671769.html
Copyright © 2011-2022 走看看