Ehcache配置遇到Content is not allowed in prolog异常的解决办法

项目中使用了Hibernate,并使用Ehcache作为二级缓存,配置好了之后,启动tomcat老是出现下面的错误:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Error configuring from file:/D:/Tomcat%206.0/webapps/ROOT/WEB-INF/classes/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was Content is not allowed in prolog.
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

 

。。。。。。。

 

 

Caused by: net.sf.ehcache.CacheException: Error configuring from file:/D:/Tomcat%206.0/webapps/ROOT/WEB-INF/classes/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was Content is not allowed in prolog.
 at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:101)

 

 

。。。。。。。

 

Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Content is not allowed in prolog.
 at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155)
 at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:99)
 ... 52 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.

 

 

一开始看到第一个错误提示,还以为是spring或Ehcache引起的问题,后来找了很久才从Content is not allowed in prolog信息中找到解决的办法:

 

将ehcache.xml配置文件利用记事本另存为Anis编码的文件。

 

一个小问题,居然花了好长一段时间才找到原因和解决办法。

你可能感兴趣的:(spring,Hibernate,exception,Class,input,nested)