Can't load spring 3 schemas

心已入冬 提交于 2019-12-31 03:03:20

问题


i am using Spring 3.0.5.RELEASE and today when building the project with maven, i am getting following errors in appicationContext.xml file:

 - 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'.

i tried to open the schema links:

  • Spring XML Beans Schema
  • Spring Framework's declarative transaction management infrastructure
  • Spring Framework's application context support

but i always gets the page Forbidden !

here's how i am configuring the 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">

please advise how to fix this error.


回答1:


seems that the public schemas are not available anymore, so i load the schemas from the jars on the classpath instead as follows:

<?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">



回答2:


Seems you are experiencing this problem: Spring Beans Schema no longer available on the Web? Are you defining schemaLocation explicitly?

<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
                        ">


来源:https://stackoverflow.com/questions/10687511/cant-load-spring-3-schemas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!