Spring MVC中类路径扫描期间的I / O故障

时间:2013-05-08 09:56:00

标签: java xml spring spring-mvc annotations

您好我是Spring的新手,我正在尝试做一个简单的spring mvc应用程序,该应用程序接受来自客户表单的值并在UI中显示相同的值。现在问题是当我尝试在Jboss服务器中发布代码时,我收到以下错误消息:

14:40:31,555 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure during classpath scanning; nested exception is java.io.FileNotFoundException: D:\jboss-5.1.0.GA\server\default\deploy\SpringMVC.war\WEB-INF\classes\com\spring\customer\controller (The system cannot find the path specified)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:222)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)

这是我的web.xml:

<web-app 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
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>SpringMVC</display-name>
<servlet>
   <servlet-name>mvc-dispatcher</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
     <servlet-name>mvc-dispatcher</servlet-name>
     <url-pattern>*.htm</url-pattern>
</servlet-mapping>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>

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

<error-page>
<error-code>404</error-code>
<location>/WEB-INF/pages/404.jsp</location>
</error-page>

<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/pages/404.jsp</location>
</error-page>
</web-app>

Dispatcher Servlet代码如下:

<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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<context:component-scan base-package="com.spring.customer.controller" />

<bean class="com.spring.customer.validator.CustomerValidator" />

<!-- Register the Customer.properties -->
<bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="com/spring/customer/properties/Customer" />
</bean>
    <bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
      <property name="prefix">
          <value>/WEB-INF/pages/</value>
       </property>
      <property name="suffix">
         <value>.jsp</value>
      </property>
</bean>

我尝试在谷歌搜索,但找不到有什么问题。我已经为这个问题打了近2个小时。有人帮忙!!

P.S:我正在使用maven。

提前致谢

1 个答案:

答案 0 :(得分:0)

有:

<context:component-scan base-package="com.spring.customer.controller" />

似乎你的应用程序中没有这样的包,但是Spring正在搜索这个包(所以是一个目录)来查找组件。

请在二进制文件中验证您是否有此类软件包(或者您根本没有此软件包?)