Spring:单元测试Error creating bean with name 'org.springframework.web.servlet.resource.Resource

原来的单元测试代码

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:spring/*.xml" })
public class UserImportTest {
	
	@Autowired
	UserService userService;
	
	@Test
	public void importUser(){
		System.out.println("单元测试");
        //查询一个用户信息
		FjUserVo user = userService.userDetail(1);
		System.out.println(user.getName());
	}
}

运行出现问题:

Caused by: org.springframework.beans.factory.BeanCreationException: 
			Error creating bean with name ‘org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0’: Invocation of init method failed; 
			nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [ResourceHttpRequestHandler [locations=[class path resource [WEB-INF/css/]],
			resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@557a1e2d]]] does not run in a WebApplicationContext but in: org.springframework.context.support.Gene

你可能感兴趣的:(Java,#,Spring)