Spring整合Mybatis报错解决之道
Posted lovis
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring整合Mybatis报错解决之道相关的知识,希望对你有一定的参考价值。
报错
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/springmvc-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/springmvc-context.xml] cannot be opened because it does not exist Web.xml:
报错原因:
classpath:到你的class路径中查找文件,
classpath*:不仅包含class的路径,还包括jar文件中(class路径)进行查找
解决办法:在classpath后面在上“*” 可解决问题,“classpath*:springmvc.xml”
我的web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>atcrowdfunding</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/spring-*.xml</param-value>
</context-param>
<!-- 监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 字符编码过滤器 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/springmvc-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.htm</url-pattern>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 会话超时时间 -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
标红的那一行缺少一个*
以上是关于Spring整合Mybatis报错解决之道的主要内容,如果未能解决你的问题,请参考以下文章
今天整合springMVC+Mybatis时tomcat启动初始化报错一直解决不了,哪位大哥能帮帮我啊万分感谢
SpringBoot 整合Mybatis报错解决(Failed to determine a suitable driver class)