Home > OS >  Problem with Maven and a HelloWorld.java project
Problem with Maven and a HelloWorld.java project

Time:10-24

I have this in my pom.xml:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>training.maven.quick</groupId>
    <artifactId>minimal-example</artifactId>
    <version>1.0</version>
</project>
<properties>
       <maven.compiler.source>1.8</maven.compiler.source>
       <maven.compiler.target>1.8</maven.compiler.target>
</properties>

I use Git Bash and when I use:

mvn package

The problem is the following:

$ mvn package
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM C:\Users\clmonreal\MavensProject\minimal\pom.xml: sta tag not allowed in epilog but got p (position: END_TAG seen ...</version>\n</pject>\n<p... @10:3)  @ line 10, column 3
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (C:\Users\clmonreal\MavensProject\minimal\pom.xml) has 1rror
[ERROR]     Non-parseable POM C:\Users\clmonreal\MavensProject\minimal\pom.xml:tart tag not allowed in epilog but got p (position: END_TAG seen ...</version>\/project>\n<p... @10:3)  @ line 10, column 3 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swih.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please re the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildiException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseExction

CodePudding user response:

All tags in maven should be between <project> and </project>

Instead of:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>training.maven.quick</groupId>
    <artifactId>minimal-example</artifactId>
    <version>1.0</version>
</project>
<properties>
       <maven.compiler.source>1.8</maven.compiler.source>
       <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Do:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>training.maven.quick</groupId>
    <artifactId>minimal-example</artifactId>
    <version>1.0</version>

   <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
   </properties>
</project>

this is because if bar is inside foo it would be:

<foo>
   <bar>
   </bar>
</foo> <!-- close of foo -->

for more info look up xml syntax

Hope this helps

  • Related