spring 使用自动扫描的方式注入bean在用junit 4测试时报空指针异常 如果用jsp页面却没有问题
@Controller@Scope("prototype")publicclassUserAction{@ResourceprivateUserServiceuserSe...
@Controller
@Scope("prototype")
public class UserAction {
@Resource
private UserService userService;
@Test
public void testSave() {
User user = userService.getById(15L);
System.out.println(user.getName());
}
} 展开
@Scope("prototype")
public class UserAction {
@Resource
private UserService userService;
@Test
public void testSave() {
User user = userService.getById(15L);
System.out.println(user.getName());
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询