16:35:44,816 [main] ERROR ErrorLogger : Error parsing XML (18) : 注释中不允许出现字符串 "--"。
16:35:44,941 [main] ERROR ContextLoader : Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'departmentDaoImpl': Injection of resource fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ItcastOA\WEB-INF\classes\applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:292)
。。。。。。。。。。省略。。。。。。。。。。。。
Caused by: org.dom4j.DocumentException: Error on line 18 of document : 注释中不允许出现字符串 "--"。 Nested exception: 注释中不允许出现字符串 "--"。
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 68 more
在启动tomcat时会出现如上错误,同时有可能会出现xml无法解析等错误
解决办法:
注释中不能出现字符串 "--",即需要把xml文件中多余的“--”去掉,例如:
<!-- ---------Department和User对应,外键设置在多的一方,column为外键名------- -->
应该改为
<!--Department和User对应,外键设置在多的一方,column为外键名-->
这样在解析xml文件就不会出现错误了
另外,在jsp的注释中也最好也不要添加EL,例如:
<!--${}--> 这个EL表达式获取的值为空,因此页面会出现错误提示