koushick
koushick

Reputation: 497

Error in pom file while converting java project to maven

I was converting java project to maven.

I added these dependencies

<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>Tippreports</groupId>
    <artifactId>Tippreports</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.0</version>
                        <type>maven-plugin</type>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <dependencies>
                    <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-server</artifactId>
                        <version>3.141.5</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <dependencies>
                    <dependency>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                        <version>6.14.3</version>
                        <scope>test</scope>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0-M1</version>
                        <type>maven-plugin</type>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

After adding dependencies, I can't able to run as Maven install or build

The Error is

Error resolving version for plugin 'org.apache.maven.plugins:null' 
from the repositories [local (C:\Users\rck\.m2\repository),
central (http://repo.maven.apache.org/maven2)]:
Plugin not found in any plugin repository

Should I create a folder in the above specified location or do I need to change the location?

Upvotes: 0

Views: 1205

Answers (1)

LaurentG
LaurentG

Reputation: 11717

Your pom.xml is not valid against the XSD. You should first use a IDE which would show you the problems.

The correct structure is <build><plugins><plugin>, like in the following example:

<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>Tippreports</groupId>
    <artifactId>Tippreports</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.5</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M1</version>
            </plugin>
        </plugins>
    </build>
</project>

Your are also mixing plugins configuration with dependencies. The dependencies are going to a different place in the pom.xml.

Upvotes: 5

Related Questions