元素 'bean' 必须不含字符 [子级], 因为该类型的内容类型为“仅元素”

元素 'bean' 必须不含字符 [子级], 因为该类型的内容类型为“仅元素”

问题描述:

图片说明
报错,然后根据网友回答更改后
图片说明
又报错Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from class path resource [com/article3/example2/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 23; 元素类型 "bean" 必须后跟属性规范 ">" 或 "/>

第8行的class和前面的双引号中间没有空格。后面还有。

 <bean id="studentDao" ... >

这趟写,id是bean元素的属性

你括号打在了bean后面,因此di="studentDao"成为了bean的子级
因此报错