我正在使用JavaConfig进行引导配置,当我作为Spring Boot App运行本地时,它运行良好。但是,当我创建一个war文件并尝试在远程Tomcat7服务器上部署时,它抱怨没有Web上下文加载器:
错误o.s.web.context.ContextLoader - 上下文初始化失败 org.springframework.beans.factory.BeanDefinitionStoreException:从ServletContext资源解析XML文档的IOException [/< NONE> ]。嵌套异常是java.io.FileNotFoundException:无法打开ServletContext资源[/< NONE>]
在使用Spring Boot Servlet初始化程序时,是否必须声明Web上下文?
这是我目前的web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>my service</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.myserviceclass.login.WebConfig
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>