maven error: element dependency can not have character children

This is because, as others have said, there are non-printable, but XML-illegal characters inserted into pom.xml, usually between XML elements. In my case, this often happens when I copy and paste from elsewhere, usually documentation, an article, tutorial, etc. in my browser.

For me, IntelliJ IDEA's editor displays these characters as rose-colored space, perhaps a function of my color scheme, so that it's easy to find and delete them.


I recently faced that problem and the error showed at the xsi:schemaLocation of the pom.xml file and it was a problem of copy and paste from different websites introducing an invisible non-space character. To check which line have the hidden character I take a copy of the pom file and paste it to a blank word file and enable "Show paragraph mark and other formatting".


As mentioned in the comment by Powerlord, this error is due to incorrect parsing of the XML file, because there are strange and hidden characters in between a/some <dependency>...</dependency> tag(s). Those characters could come from a copy paste from the Web.

To solve the issue, remove all spaces and newline characters between <dependency>...</dependency> tags definitions and put them back into your editor.