weixin_43800178
冰冰的大白兔
2019-07-26 09:42
采纳率: 66.7%
浏览 374
已采纳

eclipse搭建springMVC框架遭遇问题

报错信息
(https://img-ask.csdn.net/upload/201907/26/1564105124_751495.png)

项目工程
(https://img-ask.csdn.net/upload/201907/26/1564105212_660152.png)

服务配置
(https://img-ask.csdn.net/upload/201907/26/1564105296_265209.png)

HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
type Exception report
message Servlet.init() for servlet springmvc threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
root cause
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource
[/classpath.springmvc.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource
[/classpath.springmvc.xml]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
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:131)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)

root cause
java.io.FileNotFoundException: Could not open ServletContext resource [/classpath.springmvc.xml]
org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
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:131)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.86 logs.

在web.xml

  <display-name>springmvcfirst</display-name>

  <!-- 前端控制器 -->
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- contextConfigLocation配置springmvc加载的配置文件 -->
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/springmvc.xml</param-value>
    </init-param>


  </servlet>


  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.action</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • qq_38069781
    有氧护膝 2019-07-26 16:55
    已采纳
    web.xml 配置
      <!-- spring mvc配置 -->
     # <servlet>
      #  <servlet-name>dispatch</servlet-name>
       # <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
        #</servlet-class>
        #<init-param>
        #       <param-name>contextConfigLocation</param-name>
            #<param-value>classpath:conf/spring-mvc.xml</param-value>
        #</init-param>
      #  <load-on-startup>1</load-on-startup>
      #</servlet>   
    
      配置springMVC.xml 路径有问题  你看下你的路径,再配置下web.xml
    
    点赞 评论
  • weixin_43800178
    冰冰的大白兔 2019-07-26 10:45

    在eclipse中的错误信息

    <unknown>
        org.apache.catalina.startup.Bootstrap at localhost:3891         
                Thread [main] (Suspended (exception FileNotFoundException))             
                    owns: URLClassPath  (id=35)             
                    owns: Class<T> (org.apache.tomcat.util.res.StringManager) (id=28)               
                    URLClassPath$JarLoader.getJarFile(URL) line: not available              
                    URLClassPath$JarLoader.access$800(URLClassPath$JarLoader, URL) line: not available              
                    URLClassPath$JarLoader$1.run() line: not available              
                    URLClassPath$JarLoader$1.run() line: not available              
                    AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]               
                    URLClassPath$JarLoader.ensureOpen() line: not available             
                    URLClassPath$JarLoader.<init>(URL, URLStreamHandler, HashMap<String,Loader>, AccessControlContext) line: not available              
                    URLClassPath$3.run() line: not available                
                    URLClassPath$3.run() line: not available                
                    AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]               
                    URLClassPath.getLoader(URL) line: not available             
                    URLClassPath.getLoader(int) line: not available             
                    URLClassPath.getNextLoader(int[], int) line: not available              
                    URLClassPath.access$100(URLClassPath, int[], int) line: not available               URLClassPath$2.next() line: not available               
                    URLClassPath$2.hasMoreElements() line: not available                
                    ClassLoader$2.hasMoreElements() line: not available             
                    CompoundEnumeration<E>.next() line: not available               
                    CompoundEnumeration<E>.hasMoreElements() line: not available                
                    ServiceLoader$LazyIterator.hasNextService() line: not available             
                    ServiceLoader$LazyIterator.hasNext() line: not available                
                    ServiceLoader$1.hasNext() line: not available               
                    ResourceBundle.<clinit>() line: not available               
                    StringManager.<init>(String, Locale) line: 75               
                    StringManager.getManager(String, Locale) line: 256              
                    StringManager.getManager(String) line: 213              
                    Catalina.<clinit>() line: 77                
                    NativeConstructorAccessorImpl.newInstance0(Constructor<?>, Object[]) line: not available [native method]                
                    NativeConstructorAccessorImpl.newInstance(Object[]) line: not available             
                    DelegatingConstructorAccessorImpl.newInstance(Object[]) line: not available             
                    Constructor<T>.newInstance(Object...) line: not available               
                    Class<T>.newInstance() line: not available              
                    Bootstrap.init() line: 211              
                    Bootstrap.main(String[]) line: 398      
        C:\Program Files\Java\jre1.8.0_191\bin\javaw.exe (2019年7月26日 上午9:50:01)
    <unknown>       
        C:\Program Files\Java\jre1.8.0_191\bin\javaw.exe (2019年7月26日 上午10:15:28)  
    
    点赞 评论
  • weixin_42334923
    Java小妹 2019-07-27 11:21

    配置springMVC.xml 路径有问题 web.xml中

    contextConfigLocation
    classpath:config/springmvc.xml

    点赞 评论

相关推荐