Search code examples
xmlspring-bootxsdxsd-validationxml-validation

cvc-complex-type.2.3 : Element 'Project' cannot have character children


I am trying to create a spring boot application, but I get some issue in my project.

<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>io.javabrains.springbootquickstart</groupId>
  <artifactId>course-api</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Java Brains Course API</name>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

   <properties><java.version> 1.8 </java.version></properties>

</project>

I'm getting this error in my pom.xml:

cvc-complex-type.2.3 : Element 'project' cannot have character [Children], because the type's content type is element-only.


Solution

  • There is a BOM in the middle of your XML file after the close of dependencies element and the start of the properties element:

    </dependencies>
    
       <properties><java.version> 1.8 </java.version></properties>
    

    The BOM is visible in a hex editor as ef bb bf, but invisible as text. BOMs can only appear at the top of an XML file, not in the middle.

    Here is your XML without the problem:

    <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>io.javabrains.springbootquickstart</groupId>
      <artifactId>course-api</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <name>Java Brains Course API</name>
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
      </parent>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
      </dependencies>
      <properties><java.version> 1.8 </java.version></properties>
    </project>
    

    I've also removed unnecessary whitespace for uniformity, but space characters and line breaks between elements are fine and can now be re-introduced per your formatting taste.