SSM中利用MockMvc测试controller出现的几个问题
- Error creating bean with name ‘locationServiceImpl’
具体见以下log
十月 21, 2018 10:58:26 上午 org.springframework.web.context.support.GenericWebApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'locationServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ssm.zsc.first.dao.LocationMapper ssm.zsc.first.service.impl.LocationServiceImpl.locationMapper; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframe.web.servlet.view.InternalResourceViewResolver] for bean with name 'org.springframe.web.servlet.view.InternalResourceViewResolver#0' defined in class path resource [spring-web.xml]; nested exception is java.lang.ClassNotFoundException: org.springframe.web.servlet.view.InternalResourceViewResolver
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at
这里仅截取了一部分。
controller部分代码:
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.