我正在尝试使用Maven和Spring在Eclipse中构建应用程序。
在我的应用程序中,一切似乎都构建良好,但是一旦部署它,我将收到以下错误消息:
org.springframework.beans.factory.BeanDefinitionStoreException:IOException从ServletContext资源[/src/main/resources/springWeb.xml]解析XML文档;嵌套的异常是java.io.FileNotFoundException:无法打开ServletContext资源[/src/main/resources/springWeb.xml]
我已经尝试了一切方法,只是更改了web.xml文件中的param-value,但没有任何效果。
这是我的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>Olympus</display-name>
<servlet>
<servlet-name>springLoginApplication</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>src/main/resources/springWeb.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springLoginApplication</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
这是我的springWeb.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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-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="org.olympus" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/" />
<property name="suffix" value=".jsp" />
</bean>
<import resource="springBeanConfiguration.xml"/>
</beans>
这是我的文件夹结构
以下配置将为您工作。使用类路径参考src / main / resources下的xml资源,例如classpath:springWeb.xml
<servlet>
<servlet-name>springLoginApplication</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springWeb.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springLoginApplication</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句