2

我正在使用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">

请告知如何解决此错误。

4

2 回答 2

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">
于 2012-05-21T15:34:55.463 回答
4

似乎您遇到了这个问题:Web 上不再提供 Spring Beans Schema?您是否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
                        ">
于 2012-05-21T14:51:33.257 回答