2013-02-22 21 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

相關問題