spring入门程序报错,知道错误不知道如何改正?

用eclipse2019配置tomcat8.5写的spring12的入门程序报错,控制台报错如下

8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/8.5.43
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Jul 4 2019 20:53:15 UTC
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         8.5.43.0
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 10
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            10.0
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             D:\Program Files\Java\jdk-12.0.2
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           12.0.2+10
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:\apache-tomcat-8.5.43
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         D:\apache-tomcat-8.5.43
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:58165
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -javaagent:D:\Users\rabbit\eclipse\java-2019-06\eclipse\configuration\org.eclipse.osgi\226\0\.cp\lib\javaagent-shaded.jar
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-8.5.43
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.5.43
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\apache-tomcat-8.5.43\webapps
8月 08, 2019 5:12:29 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
8月 08, 2019 5:12:29 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: An older version [1.2.14] of the APR based Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [1.2.23]
8月 08, 2019 5:12:29 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library [1.2.14] using APR version [1.6.2].
8月 08, 2019 5:12:29 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
8月 08, 2019 5:12:29 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
8月 08, 2019 5:12:30 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized [OpenSSL 1.0.2l  25 May 2017]
8月 08, 2019 5:12:30 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
8月 08, 2019 5:12:30 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
8月 08, 2019 5:12:30 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
8月 08, 2019 5:12:30 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
8月 08, 2019 5:12:30 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2129 ms
8月 08, 2019 5:12:30 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Catalina]
8月 08, 2019 5:12:30 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.5.43
8月 08, 2019 5:12:30 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor [D:\apache-tomcat-8.5.43\conf\Catalina\localhost\springmvcfirst.xml]
8月 08, 2019 5:12:30 下午 org.apache.catalina.startup.HostConfig deployDescriptor
警告: A docBase [D:\apache-tomcat-8.5.43\webapps\springmvcfirst] inside the host appBase has been specified, and will be ignored
8月 08, 2019 5:12:31 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
8月 08, 2019 5:12:31 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
8月 08, 2019 5:12:31 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:614)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1823)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
    ... 25 more

8月 08, 2019 5:12:31 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
8月 08, 2019 5:12:32 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
警告: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [306] milliseconds.
8月 08, 2019 5:12:32 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/springmvcfirst] startup failed due to previous errors
8月 08, 2019 5:12:32 下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext

附配置文件
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>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>

  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <servlet-mapping>
    <servlet-name>spring</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>

springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- Handler -->
    <bean name="/queryItems.action" class="cn.itcast.ssm.controller.ItemsController1"/>

    <!-- 处理器映射器 -->
    <bean
            class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    <!-- 处理器适配器 -->
    <bean
            class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
    <!-- 视图解析器  -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean>

</beans>

2个回答

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring/spring-application.xml</param-value>
    </context-param> 

tiankongzhichenglyf
tkzc_shark 回复冰冰的大白兔: 加载Spring配置文件,配置文件中是我们需要往Spring容器中注册的Bean对象配置
10 个月之前 回复
weixin_43800178
冰冰的大白兔 回复tkzc_shark: 这样加载的就是spring里的applicationContext了是吧
10 个月之前 回复
tiankongzhichenglyf
tkzc_shark 回复冰冰的大白兔: https://www.cnblogs.com/yanqingguo/p/9856089.html
10 个月之前 回复
tiankongzhichenglyf
tkzc_shark 回复冰冰的大白兔: web.xml中添加你的spring-applicationContext.xml
10 个月之前 回复
weixin_43800178
冰冰的大白兔 你好请问是什么意思呢
10 个月之前 回复

applicationContext.xml 这个配置文件内容是什么,报错可能是这里面配置的 Bean 有问题。

weixin_43800178
冰冰的大白兔 没有这个文件问题是
10 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐