Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MavenError: Failed to execute goal on project: Could not resolve dependencies In Maven Multimodule project

I am trying to create a maven multi-module project. the project is created successfully but when I am trying to use one module as a dependency of another module, it throws an exception. When I create a module using eclipse, I was selecting packaging as a jar, but when the module is created, the packaging tag was not mention in child pom.xml and I manually insert the packaging tag as a jar. following is my parent 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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.netsol</groupId> <artifactId>empirecl</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> ------------------------- <modules>     <module>empirecl-web</module>     <module>empirecl-dao</module>     <module>empirecl-service</module>     <module>empirecl-api</module> </modules> 

Dao Child Module:

<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> <parent>     <groupId>com.netsol</groupId>     <artifactId>empirecl</artifactId>     <version>0.0.1-SNAPSHOT</version>     <relativePath>../pom.xml</relativePath> </parent> <artifactId>empirecl-dao</artifactId> <packaging>jar</packaging> <name>empirecl-dao</name> ------------------------ 

Service Child Module:

<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> <parent>     <groupId>com.netsol</groupId>     <artifactId>empirecl</artifactId>     <version>0.0.1-SNAPSHOT</version>     <relativePath>../pom.xml</relativePath> </parent> <artifactId>empirecl-service</artifactId> <packaging>jar</packaging> <name>empirecl-service</name>  <dependencies>     <dependency>         <groupId>com.netsol</groupId>         <artifactId>empirecl-dao</artifactId>         <version>0.0.1-SNAPSHOT</version>         <type>jar</type>     </dependency> ------------------------------------------ 

The Dao module maven clean and install successfully, but when i trying to use service module, it will generate an following exception:

[ERROR] Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Could not find artifact com.netsol:empirecl:pom:0.0.1-SNAPSHOT -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT 

I am trying the find to solution from web, but still the solution is not found. In eclipse when i open the Dependency Hierarchy of service module, it shown the DAO module as a folder not jar. below is the screen shot of Dependency Hierarchy of service module.

enter image description here

like image 741
Harmeet Singh Taara Avatar asked Jul 10 '14 10:07

Harmeet Singh Taara


Video Answer


2 Answers

In case anybody comes back to this, I think the problem here was failing to install the parent pom first, which all these submodules depend on, so the Maven Reactor can't collect the necessary dependencies to build the submodule.

So from the root directory (here D:\luna_workspace\empire_club\empirecl) it probably just needs a:

mvn clean install 

(Aside: <relativePath>../pom.xml</relativePath> is not really necessary as it's the default value).

like image 196
declension Avatar answered Sep 28 '22 13:09

declension


In my case I forgot it was packaging conflict jar vs pom. I forgot to write

<packaging>pom</packaging> 

In every child pom.xml file

like image 22
Sultan1991 Avatar answered Sep 28 '22 13:09

Sultan1991