I have created one spring boot maven project. There is one parent pom.xml. Parent pom has 4 modules. Following is the parent pom.xml
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.8</version>
</parent>
<groupId>com.xyz</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>xyz</name>
<description>xyz project</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.1</spring-cloud.version>
<project.version>1.0.0-SNAPSHOT</project.version>
<spock-spring.version>2.1-groovy-3.0</spock-spring.version>
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
</properties>
<dependencies>...</dependencies>
<modules>
<module>xyz-common</module>
<module>xyz-notification</module>
<module>xyz-issue</module>
<module>xyz-logger</module>
</modules>
</project>
In xyz-notification module there is a dependency of xyz-common. Following is the pom of xyz-common:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>xyz-common</artifactId>
<name>xyz-common</name>
<packaging>jar</packaging>
<description>xyz Common Module</description>
<version>1.0.0-SNAPSHOT</version>
</project>
Following is the pom of xyz-notification:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz</groupId>
<artifactId>xyz-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>xyz-notification</artifactId>
<name>xyz-notification</name>
<description>xyz notification module</description>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>xyz-common</artifactId>
<version>${project.version}</version>
</dependency> ...
</dependencies>
</project>
First common is build mvn -pl xyz-common clean install
and then xyz-notification mvn -pl xyz-notification clean install
But I am getting an error while building xyz-notification:
Failed to execute goal on project xyz-notification: Could not resolve dependencies for project com.xyz:xyz-notification:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.xyz:xyz-common:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for com.xyz:xyz-common:jar:1.0.0-SNAPSHOT: Could not find artifact com.xyz:xyz-parent:pom:1.0.0-SNAPSHOT ->
How to solve this?