Element ‘dependency’ cannot have character [children]
我经常在网上去复制Maven依赖,和Spring中的配置信息
这个时候可能会复制显示总是有错误
编写依赖,感觉没有错误,但是就不进行下载
问题
- 看看你的特殊字符多写、少些、写错。
- .连接符出有空格
- 标签后面有空格
- 拼写错误
Element ‘bean’ cannot have character [children], because the type’s content type is element-only
报错如下
Element 'project' cannot have character [children], because the type's content type is element-only.
或
Element 'beans' cannot have character [children], because the type's content type is element-only.
可能的原因
配置文件中Beans节点下只能是元素节点,不可有多余字符或文本存在,也可能是多余的空格。
可能由于复制操作,产生了不可见字符;
也可能由于不小心按到了键盘上的按键,在标签外产生了多余的字符。
解决方法
查找文件中的多余文本字符,删除即可(空行不影响)