分配置文件在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");
	}

}

  

相关文章:

  • 2022-01-11
  • 2021-10-24
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-10
相关资源
相似解决方案