在用maven的时候遇到报错:
Element 'dependency' cannot have character [children], because the type's content type is element-only.
报错内容如下:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
问题的原因是里面存在不可见的空白字符,通常是复制粘贴造成的。
比如说上面存在一个中文空格
,也就是,跟普通的英文空格不一样:
。
但如果你找不到哪里出了问题,重新手打一遍也可以解决问题。
参考:* java - maven error: element dependency can not have character children - Stack Overflow