配置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)中,我得到的錯誤。 我的頭腦被吹了,我被卡住了....如何擺脫這個錯誤?請指導! :(
嗯。你的XML解析器似乎在抱怨實際的模式(http://www.springframework.org/schema/beans/spring-beans-3.1.xsd),這很奇怪。我原以爲這是有效的。我很快看了看,沒有看到任何明顯的問題。你正在使用哪個XML解析器? – 2013-02-22 18:23:12
嗯..我使用Eclipse作爲我的IDE。它顯示錯誤。 – LittleLebowski 2013-02-22 18:42:23