无法加载spring 3架构

时间:2012-05-21 14:47:58

标签: spring applicationcontext

我正在使用 Spring 3.0.5.RELEASE 今天用maven构建项目时,我在 appicationContext.xml 文件中遇到以下错误:

 - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 
     'context:component-scan'.
 - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-
 config'.
 - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx: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:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
           http://www.springframework.org/schema/beans     
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/tx 
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context 
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">

请告知如何解决此错误。

2 个答案:

答案 0 :(得分:6)

似乎公共模式不再可用,所以我从类路径的jar中加载模式,如下所示:

<?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:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="  
           http://www.springframework.org/schema/beans 
           classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd
           http://www.springframework.org/schema/tx
           classpath:/org/springframework/transaction/config/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context  
           classpath:/org/springframework/context/config/spring-context-3.0.xsd">

答案 1 :(得分:4)

您似乎遇到了这个问题:Spring Beans Schema no longer available on the Web?您是否明确定义了schemaLocation

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/context/spring-context-3.0.xsd
                        ">