Maven error: element dependency cannot have child characters

I'm not sure what happened, but the POM for my project no longer works. He complains about the dependency element. Does addiction really no longer exist? What does this error mean? To be clear, I did not change the POM, it just does not work.

The exact error message is cvc-complex-type.2.3: Element 'dependency' cannot have a character (children), because the content type of this type is only an element.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.medfusion</groupId> <artifactId>Estatements-core</artifactId> <version>14.6.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Estatements-core</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.group.id.Launcher1</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.3.2</version> </plugin> </plugins> </build> <repositories> <repository> <id>nexus-qhg-dev</id> <name>Medfusion repo</name> <url>http://maven.qhg.local/nexus/content/groups/qhg-dev</url> </repository> </repositories> <dependencies> <dependency>  <groupId>com.intuit.health</groupId> <version>14.6.0-SNAPSHOT</version>  <artifactId>notification-reference</artifactId>   </dependency> <dependency>    <groupId>junit</groupId>    <artifactId>junit</artifactId>    <version>3.8.1</version>    <scope>test</scope>  </dependency> <dependency>   <groupId>com.intuit.health</groupId>  <version>ihg-depot-trunk-SNAPSHOT</version>  <artifactId>attachment-reference</artifactId>  </dependency> <dependency>  <groupId>com.intuit.health</groupId>  <version>ihg-depot-trunk-SNAPSHOT</version>  <artifactId>eCommunication-core</artifactId>   </dependency> </dependencies> </project> 
+16
java eclipse maven
source share
4 answers

As mentioned in Powerlord's comment, this error is due to incorrect parsing of the XML file, because between a / some there are strange and hidden characters <dependency>...</dependency> tag (s). These characters may come from folders with copies from the Internet.

To solve the problem, remove all spaces and newlines between the <dependency>...</dependency> tag definitions and return them to your editor.

+42
source share

I recently ran into this problem and the error shown in xsi: schemaLocation of the pom.xml file, and it was the problem of copying and pasting from different websites of invisible non-spatial nature. To check which line has a hidden character, I take a copy of the pom file and paste it into an empty word file and turn on "Show paragraph marker and other formatting."

+1
source share

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

For me, the IntelliJ IDEA editor displays these characters as a pink space, possibly a function of my color scheme, so it's easy to find and remove.

+1
source share

This is because you tried to copy, paste dependencies from the Internet, and there are some special or hidden characters that cause errors of this type. Therefore, first copy to a text file, then paste it into the code to avoid this type of error.

0
source share

All Articles