2013-02-22 53 views
0

配置Hibernate时,我的配置文件中出现以下错误。获取错误:架构不能包含两个同名的全局组件

Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.1.xsd) 

当我检查“详细信息”,它给了我如下:

sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/beans,identifiedType'. 

我有它的模式定义(其中导入我的休眠-context.xml文件的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:p="http://www.springframework.org/schema/p" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.1.xsd 
      http://www.springframework.org/schema/mvc 
      http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 

.. 
.. 
<!-- Imports datasource configuration --> 
<import resource="hibernate-context.xml" /> 

我的Hibernate的context.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:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation=" 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-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/context 
      http://www.springframework.org/schema/context/spring-context-3.1.xsd 
      http://www.springframework.org/schema/jdbc 
      http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd 
      http://www.springframework.org/schema/data/jpa 
      http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 
      http://www.springframework.org/schema/util 
      http://www.springframework.org/schema/util/spring-util-3.1.xsd 
      http://www.springframework.org/schema/mvc 
      http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
      "> 

这是在这个文件(hibernate-context.xml)中,我得到的错误。 我的头脑被吹了,我被卡住了....如何摆脱这个错误?请指导! :(

+0

嗯。你的XML解析器似乎在抱怨实际的模式(http://www.springframework.org/schema/beans/spring-beans-3.1.xsd),这很奇怪。我原以为这是有效的。我很快看了看,没有看到任何明显的问题。你正在使用哪个XML解析器? – 2013-02-22 18:23:12

+0

嗯..我使用Eclipse作为我的IDE。它显示错误。 – LittleLebowski 2013-02-22 18:42:23

回答

6

好吧,这个问题得到了解决,我在这里写它为任何人停留在同一个无聊的情况备查

我从休眠-context.xml的改变了这一行:。

http://www.springframework.org/schema/data/jpa 
      http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 

http://www.springframework.org/schema/data/jpa 
      http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd 

我就不清楚为什么,但它解决了我得到的错误。

+0

我也有同样的错误 - 我仍然不知道为什么链接需要一个特定的版本号。 – 2013-05-05 05:14:24

+0

我面临着同样的情况,但在我的情况下没有hibernate-context.xml。你能否提供一些关于你如何调试问题的细节? – Tk421 2015-11-27 06:15:36

相关问题