Junit4 测试代码
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:/META-INF/spring-context.xml"})
public class JunitTest {
@Autowired
private UserService userService;
@Test
public void test1(){
User user = userService.queryById(1);
}
}
- 就可以测试service层的代码
- 对于多模块maven ssm项目不用install