IDEA中导入Eclipse所做旅游项目,运行测试类时,此时出现该错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcContentNegotiationManager': Failed to introspect bean class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
解决方法:在pom.xml 文件中添加依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
添加完依赖后运行测试类,此时又出现错误
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.tedu.ttms.product.dao.ProjectDao.findObjects
解决方法:在pom.xml文件的build标签中配置resource:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
之后,测试类正常运行,问题解决。