0

我有简单的网络应用程序(spring 3 + thymeleaf,部署在 glassfish 3.x 上)。当我尝试运行它时,出现错误:

SEVERE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 24; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.

这是我的 applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/context/spring-mvc-3.1.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
          <context:component-scan base-package="arek" />
         <mvc:annotation-driven></mvc:annotation-driven>
   </beans>

我搜索但没有。感谢帮助。

4

2 回答 2

3

尝试http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd代替http://www.springframework.org/schema/context/spring-mvc-3.1.xsd.

希望这可以帮助。

于 2013-07-06T12:11:18.140 回答
0

您尝试在应用程序上下文 ( http://www.springframework.org/schema/context/spring-mvc-3.1.xsd ) 中引用的 spring MVC 模式文件不存在。自己在浏览器中打开此链接,您将看到 404 错误。最新的 MVC 模式文件位置是 ( http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd )。使用它,你不会得到异常。

于 2016-02-12T03:34:06.980 回答