spring 发生xml.sax.SAXParseException异常

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Line 2 in XML document from file [D:\Eclipse Workspace\MyEclipse 5.1\workspace\spring1\bean.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".

解决方法:
加一行:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd">
原因:没有申明类型即DTD文档类型定义

你可能感兴趣的:(eclipse,spring,xml,bean,MyEclipse)