java - Spring mvc 不适用于 AWS elastic beanstalk

标签 java spring spring-mvc amazon-web-services amazon-elastic-beanstalk

我尝试在 Amazon Elastic Beanstalk 中使用 Spring MVC,但失败了, 但是当我在本地主机上运行时,它工作得很好。

AWS 给我这个错误

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 62; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'resources'.
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

这是我的 servlet 上下文,我相信 aws 指出 “web-resources/” 映射 =“/resources/**” “

行是问题所在,我已经检查、仔细检查并再次检查架构位置是否正确。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:context="http://www.springframework.org/schema/context" 
       xmlns:mvc="http://www.springframework.org/schema/mvc" 
       xmlns:p="http://www.springframework.org/schema/p" 
       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.1.xsd     
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd     
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd" >


    <!-- Turns on support for mapping requests to Spring MVC @Controller methods
         Also registers default Formatters and Validators for use across all @Controllers -->
    <mvc:annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources -->
    <mvc:resources location="/resources/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>

    <!-- register "global" interceptor beans to apply to all registered HandlerMappings -->
    <mvc:interceptors>
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang"/>
    </mvc:interceptors>

    <!-- Resolves localized messages*.properties and application.properties files in the application to allow for internationalization. 
        The messages*.properties files translate messages, the application.properties
        resource bundle localizes all application specific messages such as entity names and menu items. -->
    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false"/>

    <!-- store preferred language configuration in a cookie -->
    <bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver" id="localeResolver" 
        p:cookieName="locale"/> 


    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <context:component-scan base-package="com.myweb.web.controller" />

</beans>

请帮助我

最佳答案

问题解决了,显然是因为elasticbeans无法加载我上传的最新版本,

我尝试删除环境并再次上传.war,它有效

谢谢

关于java - Spring mvc 不适用于 AWS elastic beanstalk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13526668/

相关文章:

java - 无法使用 Spring 访问 Maven 属性

java - 为什么我的 JFrame 没有出现在基于 Web 的 Java 应用程序中?

java - 如何使用 Eclipse Collections 将 MutableMap 转换为 ObjectDoubleMap?

java - Java 二维对象数组排序

css - 使用 spring security 和 thymeleaf 时无法加载我的 css

java - JPA Query with HQL and pageable create subselect with * return 并生成别名错误

java - 无法解析位置/'资源/

java - Spring WS 2.1.0 : Endpoint interceptors order

java - Spring Security 删除用户 - session 仍然有效

java - NoSuchBeanDefinitionException 如何初始化 SessionFactory bean?