标签:
<1>读取文件:
配置文件在classes下:locations = {"classpath*:/spring/applicationContext.xml"}
配置文件在web-inf下:locations = {"file:web/WEB-INF/applicationContext.xml"}
<2>实例类:
package com.test;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.entity.User;
import com.service.impl.UserService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"file:web/WEB-INF/applicationContext.xml"})
public class PageTest {
@Autowired
private UserService userService;
@Test
public void testPage(){
// add your test code
}
}
}
标签:
原文地址:http://www.cnblogs.com/meisp/p/5559775.html