Issue
I am having some problem with my maven dependencies in a multi-module project using IntelliJ.
The following is the structure of my maven modules:
(1) venus
is the root module.
(2) architect
is the parent module of architect-com
module.
(3) actions-com
is the child module of actions
module and services
is the parent module of actions
module.
(4) architect
and services
are direct children of the root module
- venus
- architect
- architect-com
- src [java classes here]
- services
- actions
- actions-com
- src [java classes here]
architect, services and actions modules don't have a src folder (I deleted them because I think parent modules don't need the src folders.)
Here are the POM of the modules.
// Venus - Root module
<?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>co.shock</groupId>
<artifactId>venus</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>services</module>
<module>services/actions</module>
<module>services/actions/actions-com</module>
<module>architect</module>
<module>architect/architect-com</module>
</modules>
<packaging>pom</packaging>
</project>
// architect
<?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>
<parent>
<artifactId>venus</artifactId>
<groupId>co.shock</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>architect</name>
<groupId>co.shock.jupiter</groupId>
<artifactId>architect</artifactId>
<packaging>pom</packaging>
<modules>
<module>architect-com</module>
</modules>
</project>
// architect-com
<?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>
<parent>
<artifactId>architect</artifactId>
<groupId>co.shock.venus</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>Architect - Com</name>
<groupId>co.shock.venus.architect</groupId>
<artifactId>architect-com</artifactId>
<dependencies>
// SPRING AND HIBERNATE DEPENDENCIES HERE
</dependencies>
</project>
// services
<?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>
<parent>
<artifactId>venus</artifactId>
<groupId>co.shock</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>Services</name>
<groupId>co.shock.venus</groupId>
<artifactId>services</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>actions</module>
</modules>
</project>
// actions
<?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>
<version>1.0-SNAPSHOT</version>
<parent>
<artifactId>services</artifactId>
<groupId>co.shock.venus</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>Services - Actions</name>
<groupId>co.shock.venus.services</groupId>
<artifactId>actions</artifactId>
<packaging>pom</packaging>
<modules>
<module>actions-com</module>
</modules>
</project>
// actions-com
<?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>
<parent>
<artifactId>actions</artifactId>
<groupId>co.shock.venus.services</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>Services - Actions - Com</name>
<groupId>co.shock.venus.services.actions</groupId>
<artifactId>actions-com</artifactId>
<dependencies>
<dependency>
<groupId>co.shock.venus.architect</groupId>
<artifactId>architect-com</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The actions-com
module imports architect-com
as can be seen in de above pom. When i compile the actions-com
module i get the following errors:
C:\3_projects\venus\services\actions\actions-com>mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< co.shock.venus.services.actions:actions-com >---------
[INFO] Building Services - Actions - Com 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.256 s
[INFO] Finished at: 2020-12-29T21:02:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project actions-com: Could not resolve dependencies for project co.shock
.venus.services.actions:actions-com:jar:1.0-SNAPSHOT: Failed to collect dependencies at co.shock.venus
.architect:architect-com:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for co.shock.venus
.architect:architect-com:jar:1.0-SNAPSHOT: Could not find artifact co.shock:venus:pom:1.0-S
NAPSHOT -> [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 is the path to my .m2
repository where architect-com is built. Here is the content of the snapshot folder
C:\Users\user\.m2\repository\co\shock\venus\architect\architect-com\1.0-SNAPSHOT
- _remote.repositories
- architect-com-1.0-SNAPSHOT.jar
- architect-com-1.0-SNAPSHOT.pom
- maven-metadata-local.xml
What am I doing wrong?
Solution
Look at the last sentence of the error msg: Could not find artifact co.shock:venus:pom:1.0-SNAPSHOT
services
contains:
<parent>
<artifactId>venus</artifactId>
<groupId>co.shock</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
but Venus contains:
<groupId>co.shock</groupId>
<artifactId>jupiter</artifactId> <!-- should be 'venus' -->
<version>1.0-SNAPSHOT</version>
You simply mixed up the planets. :)
Answered By - Gerold Broser