isme
isme

Reputation: 190

Maven build dependency issue

i have issue while importing .jar of child project (model) to my other projects

Child1,2 and 3 each dependent on parent.

Upon building parent it build child 1,2 jar and child 3 war.

Child 1 is a model jar that will be use in other module.

Upon adding the jar to other modules it looking for parent.

How do I resolve such that I can use child1 as model jar to other module?

Here is my POM parent

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.7</version>
    <relativePath/>
</parent>

<groupId>com.myproject</groupId>
<artifactId>myproject-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name> MyProject POM</name>
<modules>
    <module>/myprojectModel</module>
    <module>/myproject</module>
    <module>/myprojectService</module>
</modules>

Here is my Child 1 pom

<parent>
    <groupId>com.myproject</groupId>
    <artifactId>myproject-parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath/>
</parent>
<groupId>com.emc.nrp</groupId>
<artifactId>nemsprerequisite-model</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name> Myproject Model</name>

So it will build 3 package

- Child1.jar

- Child2.jar

- Child3.war

When i import Child1.jar to another package it appear to have

Non-resolvable parent POM

This is the issue.

ERROR [io.undertow.request] (default task-91) UT005023: Exception handling request to /business-central/maven2: java.lang.RuntimeException: org.apache.maven.project.ProjectBuildingException: 1 problem was encountered while building the effective model for com.myproject.myproject-model:1.0.0-SNAPSHOT

[FATAL] Non-resolvable parent POM for com.myproject.myproject-model:1.0.0-SNAPSHOT: Could not find artifact com.myproject.myproject-parent:pom:1.0.0-SNAPSHOT @ line 5, column 10

Upvotes: 0

Views: 174

Answers (2)

KayV
KayV

Reputation: 13855

  1. Right click on src/java directory of all modules, and Click "Mark Directory as" and then click "Sources Root" as shown in below screenshot:
  2. enter image description hereselect as sour

2.I think you should create on more module which loads all the child dependencies and have only Application.java in that module.

Follow this link for more details.

Upvotes: 1

kutschkem
kutschkem

Reputation: 8163

The relativePath element in your child pom is empty. Set that.

Upvotes: 0

Related Questions