2012-05-21 70 views
2

我使用春3.0.5.RELEASE 今天用Maven构建项目时,我得到以下错误在appicationContext.xml文件:无法加载弹簧3种模式

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

请告知如何解决这个错误。

回答

6

看来,公共模式不可用了,所以我加载从罐子的模式在类路径上,而不是如下:

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

是的,我将其定义明确,我编辑我的答案,我使用这种方法很长一段时间,但它今天停止工作,我不知道为什么。 –

+0

@Msaleh:看到我指的链接,你不是唯一的。 –