[size=medium]项目中运用了Hibernate3,报错如下:[/size]
[size=medium]xml配置文件如下:[/size]
[size=medium]看不出错在哪里吧,哈哈,真正的错误原因就在xml文件的第一行是空行,去掉空行就正确了,看命令行错误提示“Error parsing XML”后,只知道是这个配置文件的问题,查看字段和hql,没有找到原因(能找到才怪 :oops: ),确实很悲催吧。。[/size]
INFO [main] - Mapping class: com.liany.demo.st.managesectioninfo.model.ManageSe
ctionInfo -> demo_ST_MANAGESECTIONINFO
ERROR [main] - Error parsing XML: XML InputStream(2) The processing instruction
target matching "[xX][mM][lL]" is not allowed.
ERROR [main] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'transactionManager' defined in class path resource [config/itop/tor/TORC
onfig.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean
property 'sessionFactory'; nested exception is org.springframework.beans.factor
y.BeanCreationException: Error creating bean with name 'sessionFactory' defined
in file [F:\projects\zjxm2011\Trunk\gl\war\WEB-INF\classes\com\liany\ipms\ipms
-spring-global.xml]: Initialization of bean failed; nested exception is org.hibe
rnate.InvalidMappingException: Could not parse mapping document from input strea
m
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'sessionFactory' defined in file [F:\projects\zjxm2011\Trunk\gl\war\WEB
-INF\classes\com\liany\ipms\ipms-spring-global.xml]: Initialization of bean fail
ed; nested exception is org.hibernate.InvalidMappingException: Could not parse m
apping document from input stream
org.hibernate.InvalidMappingException: Could not parse mapping document from inp
ut stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:527
)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPrope
rtiesSet(LocalSessionFactoryBean.java:683)
[size=medium]xml配置文件如下:[/size]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.liany.demo.st.station.model.PDA" table="DEMO_RE_PDA">
<id name="id" type="java.lang.String" column="ID">
<generator class="uuid.hex" />
</id>
<property
name="stationId"
type="java.lang.String"
column="STATIONID"
length="64"
/>
<property
name="pdaNo"
type="java.lang.String"
column="PDANO"
length="50"
/>
</class>
<query name="getPDAsByStationId">
from PDA c
where c.stationId = :stationId
</query>
<query name="getRecordCountByPDANo">
select count(*) as recordCount from PDA c
where c.pdaNo = :pdaNo
</query>
<query name="deletePDAsByStationId">
delete from PDA c
where c.stationId = :stationId
</query>
</hibernate-mapping>
[size=medium]看不出错在哪里吧,哈哈,真正的错误原因就在xml文件的第一行是空行,去掉空行就正确了,看命令行错误提示“Error parsing XML”后,只知道是这个配置文件的问题,查看字段和hql,没有找到原因(能找到才怪 :oops: ),确实很悲催吧。。[/size]