I'm using the followin folder structure:
SpringMvcExample
\_ pom.xml (root pom)
\_ parent
\_ pom.xml (parent pom)
\_ model
\_ src
\_ pom.xml (child pom)
Here are files examples:
root.pom:
<groupId>com.pack</groupId>
<artifactId>SpringMvcExample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SpringMvcExample</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>package</defaultGoal>
</build>
<modules>
<module>parent</module>
<module>model</module>
</modules>
parent pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.pack</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pack</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
model pom:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pack</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<groupId>com.pack</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
<name>model</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
When I try to invoke mvn clean install from the model folder I'm getting the following error:
[ERROR] Failed to execute goal on project model: Could not resolve dependencies for project com.pack:model:jar:1.0-SNAPSHOT: Could not find artifact com.pack:model:jar:1.0-SNAPSOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project model: Could not resolve dependencies for project com.pack:model:jar:1.0-SNAPSHOT: Could not find artifact com.pack:model:jar:1.0-SNAPSHOT
What should I do to resolve it?
Updated: Cause not all people have met with the same structure, here is a link to blog that describes it, its advantages and drawbacks. And here is an example that I'm trying to reuse.