在Spring MVC中的类路径扫描期间的I / O失败(<component-scan>)

时间:2018-04-20 06:48:10

标签: java spring spring-mvc jboss jboss5.x

我是春天的新手。我创建了一个应用程序,并试图将其部署到Jboss 5。

我的申请结构是:Project Folder Structure

War Folder Structure

War Web-INF Structure

JAR Content - Controller Present

当我运行服务器时出现错误:

2018-04-19 18:49:50,913 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (main) deploy, ctxPath=/TestJsp
2018-04-19 18:49:51,095 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/TestJsp]] (main) Initializing Spring FrameworkServlet 'springDispatcher'
2018-04-19 18:49:51,097 INFO  [org.springframework.web.servlet.DispatcherServlet] (main) FrameworkServlet 'springDispatcher': initialization started
2018-04-19 18:49:51,136 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (main) Refreshing WebApplicationContext for namespace 'springDispatcher-servlet': startup date [Thu Apr 19 18:49:51 IST 2018]; root of context hierarchy
2018-04-19 18:49:51,208 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (main) Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
2018-04-19 18:49:51,386 ERROR [org.springframework.web.servlet.DispatcherServlet] (main) Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure during classpath scanning; nested exception is java.io.FileNotFoundException: C:\jboss-5.1.0.GA\server\default\deploy\TestJsp.ear\TestJsp.jar\com\springController (The system cannot find the path specified)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:227)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:200)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)

Caused by: java.io.FileNotFoundException: C:\jboss-5.1.0.GA\server\default\deploy\TestJsp.ear\TestJsp.jar\com\springController (The system cannot find the path specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:129)

Web.xml中

<display-name>TestJsp</display-name>
<description>WebApplication</description>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
<servlet>  
     <servlet-name>springDispatcher</servlet-name>  
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>  
</servlet>
<servlet-mapping> 
     <servlet-name>springDispatcher</servlet-name>  
     <url-pattern>/</url-pattern>
</servlet-mapping>

弹簧servlet.xml中

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.springController" /> 
<mvc:annotation-driven/>
<context:annotation-config />
<bean name="helloController"
    class="com.springController.HelloWorldController" />

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

虽然我的JAR让控制器位于正确的位置。

请告诉我如何在服务器启动时删除此错误。

0 个答案:

没有答案