Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: Could Not find Artifact when trying to include a project in another one using dependencies

Problem description

I have a project called reservationVol which I want to include in an mvc spring project called reservationVolMvc. I compiled and tested reservationVol on eclipse. I also use the maven commands: mvn compile and mvn package. All tests ran successfully.

When I tried to compile reservationVolMvc using the mvn compile command I get the following error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building reservationVolSpring 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for hani.reservationVol:reservationVol:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.688 s
[INFO] Finished at: 2016-11-23T12:25:21+01:00
[INFO] Final Memory: 6M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project reservationVolSpring: Could not resolve dependencies for project formation.addstones:reservationVolSpring:war:1.0-SNAPSHOT: Could not find artifact hani.reservationVol:reservationVol:jar:1.0-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

The following pom.xml files represent the dependencies for respectively reservationVol and reservationVolMvc. I included the project ReservationVol in reservationVolMvc by using the following:

<dependency>
    <groupId>hani.reservationVol</groupId>
    <artifactId>reservationVol</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

ReservationVol

  <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>hani.reservationVol</groupId>
        <artifactId>reservationVol</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>reservationVol</name>
        <dependencies>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.39</version>
                <scope>compile</scope>
            </dependency>
            
             <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>5.1.0.Final</version>
            </dependency>
            
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>5.1.0.Final</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>4.2.6.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>4.2.6.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-dbcp2</artifactId>
                <version>2.1.1</version>
            </dependency>
            
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
           
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>4.2.5.RELEASE</version>
            </dependency>
        </dependencies>
    
        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.3</version>
              <configuration>
                <source>1.8</source>
                <target>1.8</target>
              </configuration>
            </plugin>
          </plugins>
        </build>
        
    </project>

reservationVolMvc

<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>formation.addstones</groupId>
    <artifactId>reservationVolSpring</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>reservationVolSpring</name>
    <dependencies>
        <dependency>
                <groupId>hani.reservationVol</groupId>
                <artifactId>reservationVol</artifactId>
                <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.7.5</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.2.Final</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
like image 344
Hani Goc Avatar asked Nov 23 '16 11:11

Hani Goc


People also ask

How do I fix missing artifact in Maven?

Try right-clicking on the project and select Maven->Update Project. Disable then re-enable dependency management (right-click Maven->Disable Maven Nature then to again convert the project to a Maven project, Right Click on the project and select Configure ->Convert To Maven Project.

What is missing artifact error in POM xml?

The error in pom. xml “missing artifact maven” occurs when the artifact is missing in local repository and remote repository. In eclipse, missing artifact maven error shows in the programs window. Maven is a software tool for building artifacts.

How does Maven solve dependency conflict?

Enforcer can help developers solve dependency conflicts in Maven by analyzing all libraries declared in the POM file. The plugin uses a lot of different rules, but we are only interested in one: dependencyConvergence – ensures all dependencies converge to the same version.


1 Answers

Do a mvn clean install.
This will clean whatever created from the previous build, then build your project and add the jars to your local maven repository (.m2\repository)

like image 161
Jobin Avatar answered Oct 14 '22 17:10

Jobin