提示这个错误?请老师帮忙分析一下

提示这个错误?请老师帮忙分析一下

HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet.init() for servlet [SpringMVC] threw exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet.init() for servlet [SpringMVC] threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)
Root Cause
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-dao.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-dao.xml] cannot be opened because it does not exist
	org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
	org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224)
	org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195)
	org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
	org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
	org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
	org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:636)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)

项目路劲:http://img1.sycdn.imooc.com//climg/5c8a2295000113de07250656.jpg


http://img1.sycdn.imooc.com//climg/5c8a22ac0001ff0106390579.jpg

admin配置文件:<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd">

   <import resource="spring-dao.xml"/>

   <context:component-scan base-package="com.imooc.book.controller"/>
   <mvc:annotation-driven/>

   <mvc:default-servlet-handler/>

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
       <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
       <property name="prefix" value="/WEB-INF/pages/"/>
       <property name="suffix" value=".jsp"/>
   </bean>

</beans>


web配置文件:<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
        version="3.1">

 <!--<filter>-->
   <!--<filter-name>encoding</filter-name>-->
   <!--<filter-class>com.imooc.oa.global.EncodingFilter</filter-class>-->
   <!--<init-param>-->
     <!--<param-name>encoding</param-name>-->
     <!--<param-value>utf-8</param-value>-->
   <!--</init-param>-->
 <!--</filter>-->
 <!--<filter-mapping>-->
   <!--<filter-name>encoding</filter-name>-->
   <!--<url-pattern>/*</url-pattern>-->
 <!--</filter-mapping>-->

 <servlet-mapping>
   <servlet-name>default</servlet-name>
   <url-pattern>/css/*</url-pattern>
   <url-pattern>/img/*</url-pattern>
   <url-pattern>*.js</url-pattern>
   <url-pattern>*.jpg</url-pattern>
   <url-pattern>*.gif</url-pattern>
   <url-pattern>*.png</url-pattern>
   <url-pattern>*.css</url-pattern>
 </servlet-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-dao.xml</param-value>
   </init-param>
   <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>SpringMVC</servlet-name>
   <url-pattern>/</url-pattern>
 </servlet-mapping>

</web-app>


spring-dao 配置文件:<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">

   <context:component-scan base-package="com.imooc.book.dao"/>

   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
       <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
       <property name="url" value="jdbc:mysql://localhost:3306/book?useUnicode=true&amp;characterEncoding=utf-8"/>
       <property name="username" value="root"/>
       <property name="password" value="123"/>
   </bean>

   <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="typeAliasesPackage" value="com.imooc.book.entity"/>
   </bean>

   <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="sqlSessionFactoryBeanName" value="sessionFactory"/>
       <property name="basePackage" value="com.imooc.book.dao"/>
   </bean>

</beans>

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕阿莹 2019-03-14 19:06:42

报错显示:这个spring-dao.xml不存在。

http://img1.sycdn.imooc.com//climg/5c8a34bd0001fec907300113.jpg

同学这是两个项目么?怎么看着不一样呢?这个web.xml是在哪个项目中配置的呢?

http://img1.sycdn.imooc.com//climg/5c8a35a10001098507940832.jpg

同学具体是在哪里配置的呢?

祝学习愉快

  • 提问者 慕粉4103086 #1
    web.xml在admin模块中配置的。
    2019-03-14 19:30:05
  • 提问者 慕粉4103086 #2
    一个项目工程 book8 ,然后建立了一个后台子模块admin 。web.xml在admin模块中配置的。报错就是找不到这个spring-dao.xml不存在。
    2019-03-14 19:51:00
  • 好帮手慕阿莹 回复 提问者 慕粉4103086 #3
    但是这个spring-dao.xml是在其他模块儿中写的吧?看到同学的模块admin下,resources文件夹下的是spring-admin.xml 。如果是,同学有在admin模块的pom文件中依赖另一个模块儿吗?祝学习愉快。
    2019-03-15 11:47:11
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
SSM主流框架入门与综合项目实战2018版
  • 参与学习           人
  • 提交作业       205    份
  • 解答问题       4317    个

Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师