Purevsuren
Purevsuren

Reputation: 11

Malformed POM: Unrecognised tag

I was trying to work on this project for school and needed to use MultiMaps from Apache.commons. I edited my pom.xml file to add that dependency and could use the import command in my IDE. But when I try to run it I get an error, it has something to do with my pom.xml file but I don't see any issues with it.

<?xml version="1.0" encoding="UTF-8"?>
<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>ClassStuff</groupId>
    <artifactId>Scheduler</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.2</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>
</project>

Upvotes: 1

Views: 2686

Answers (2)

user1438038
user1438038

Reputation: 6077

You need to wrap your dependency tags in dependencies (and maybe dependencyManagement).

You can find an example and further information on pom.xml file structure in the official Maven documentation, e.g. here: https://maven.apache.org/pom.html#Dependencies

<?xml version="1.0" encoding="UTF-8"?>
<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>ClassStuff</groupId>
<artifactId>Scheduler</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.2</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>
</dependencies>
</project>

Upvotes: 1

Dark Star1
Dark Star1

Reputation: 7413

Your <dependency></dependency> should be contained/wrapped in a <dependencies></dependencies> object.

Upvotes: 3

Related Questions