【问题标题】:Spring Web MVC with Java Configuration Error带有 Java 配置错误的 Spring Web MVC
【发布时间】:2014-11-20 04:25:26
【问题描述】:

我正在为我的 Spring Web 应用程序使用 Java 配置,但它继续在 Spring STS 中查找调度程序 xml 文件。如何进行此更改?我已将项目属性中的上下文更改为我的WebConfig class。附上日志文件:

       12:02:08.157 [http-bio-8080-exec-6] DEBUG o.s.web.servlet.DispatcherServlet - Initializing servlet 'dispatcher'
Nov 19, 2014 12:02:08 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
12:02:08.157 [http-bio-8080-exec-6] INFO  o.s.web.servlet.DispatcherServlet - FrameworkServlet     'dispatcher': initialization started
12:02:08.157 [http-bio-8080-exec-6] DEBUG o.s.web.servlet.DispatcherServlet - Servlet with name   'dispatcher' will try to create custom WebApplicationContext context of class    'org.springframework.web.context.support.XmlWebApplicationContext',      
 using parent context [Root     WebApplicationContext: startup date [Wed Nov 19 11:58:48 EST     2014]; root of context hierarchy]
12:02:08.158 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for  key 'spring.profiles.active' in [servletConfigInitParams]
12:02:08.158 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams]
  12:02:08.158 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [jndiProperties]
12:02:08.158 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.profiles.active]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name   [java:comp/env/spring.profiles.active] not found - trying original name [spring.profiles.active].   javax.naming.NameNotFoundException: Name [spring.profiles.active] is not bound in this Context.   Unable to find [spring.profiles.active].
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI  object with name [spring.profiles.active]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name     [spring.profiles.active] threw NamingException with message: Name [spring.profiles.active] is not  bound in this Context. Unable to find [spring.profiles.active].. Returning null.
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemProperties]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemEnvironment]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source. Returning [null]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [servletConfigInitParams]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [servletContextInitParams]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [jndiProperties]
12:02:08.159 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.profiles.default]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.profiles.default] not found - trying original name [spring.profiles.default]. javax.naming.NameNotFoundException: Name [spring.profiles.default] is not bound in this Context. Unable to find [spring.profiles.default].
 12:02:08.160 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [spring.profiles.default]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [spring.profiles.default] threw NamingException with message: Name [spring.profiles.default] is not bound in this Context. Unable to find [spring.profiles.default].. Returning null.
 12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemProperties]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemEnvironment]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.default' in any property source. Returning [null]
 12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [servletConfigInitParams]
 12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [servletContextInitParams]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [jndiProperties]
12:02:08.160 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.profiles.default]
 12:02:08.161 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.profiles.default] not found - trying original name [spring.profiles.default].  javax.naming.NameNotFoundException: Name [spring.profiles.default] is not bound in this Context.  Unable to find [spring.profiles.default].
12:02:08.161 [http-bio-8080-exec-6] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [spring.profiles.default]
  12:02:08.161 [http-bio-8080-exec-6] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [spring.profiles.default] threw NamingException with message: Name [spring.profiles.default] is not bound in this Context. Unable to find [spring.profiles.default].. Returning null.
   12:02:08.161 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemProperties]
  12:02:08.161 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemEnvironment]
  12:02:08.161 [http-bio-8080-exec-6] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.default' in any property source. Returning [null]
12:02:08.161 [http-bio-8080-exec-6] INFO  o.s.w.c.s.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Nov 19 12:02:08 EST 2014]; parent: Root WebApplicationContext
 12:02:08.162 [http-bio-8080-exec-6] DEBUG o.s.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
  12:02:08.162 [http-bio-8080-exec-6] DEBUG o.s.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
  12:02:08.162 [http-bio-8080-exec-6] DEBUG o.s.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
  12:02:08.162 [http-bio-8080-exec-6] INFO  o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
  12:02:08.163 [http-bio-8080-exec-6] ERROR o.s.web.servlet.DispatcherServlet - Context initialization failed
   org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML  document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is  java.io.FileNotFoundException:  
 Could not open ServletContext resource [/WEB-INF/dispatcher-servlet.xml]

【问题讨论】:

    标签: spring-mvc


    【解决方案1】:

    Spring STS 没有将我的 classes 文件夹包含在 Deployment Properties 的目标文件夹中。添加后,一切正常。

    【讨论】:

      猜你喜欢
      • 2016-06-07
      • 2017-01-27
      • 2020-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-09-28
      • 2016-04-17
      • 2016-04-19
      • 2015-04-15
      相关资源
      最近更新 更多