1

I have three child maven modules.

Parent module pom looks like this:

<?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://maven.apache.org/POM/4.0.0"
             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.abc.proj</groupId>
        <artifactId>proj</artifactId>
        <version>0.1</version>
        <packaging>pom</packaging>
        <parent>
            <groupId>com.abc.xyz</groupId>
            <artifactId>xyz-parent</artifactId>
            <version>8.247.0</version>
            <relativePath/>
        </parent>
    
        <properties>
            <java.version>11</java.version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <start-class>Application</start-class>
            <cassandra.version>3.7.1</cassandra.version>
         
        </properties>
    
        
        <name>orders</name>
        
    
        <dependencies>
    
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${springfox.swagger.version}</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${springfox.swagger.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>5.3.19</version>
            </dependency>
    
            
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
            </dependency>
            <dependency>
                <groupId>com.typesafe</groupId>
                <artifactId>config</artifactId>
                <version>1.4.2</version>
            </dependency>
            <dependency>
                <groupId>com.openpojo</groupId>
                <artifactId>openpojo</artifactId>
                <version>0.9.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-text</artifactId>
                <version>1.9</version>
            </dependency>
        
            <dependency>
                <artifactId>wiremock</artifactId>
                <groupId>com.github.tomakehurst</groupId>
                <scope>test</scope>
            </dependency>
            <dependency>
              <groupId>org.mockito</groupId>
              <artifactId>mockito-inline</artifactId>
              <scope>test</scope>
            </dependency>
        </dependencies>
    
    
      
        <modules>
            <module>commons</module>
            <module>xyz</module>
            
        </modules>
    </project>

Child Module - Common Looks like

 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://maven.apache.org/POM/4.0.0"
             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.abc.proj</groupId>
        <artifactId>proj</artifactId>
        <version>0.1</version>
      </parent>
      <groupId>com.abc.proj</groupId>
      <artifactId>commons</artifactId>
      <name>commons</name>

  
</project>
    

Child Module - xyz Looks like

<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.abc.proj</groupId>
    <artifactId>proj</artifactId>
    <version>0.1</version>
  </parent>
  
  <groupId>com.abc.proj</groupId>
  <artifactId>xyz</artifactId>
  <packaging>jar</packaging>
  
  
  <dependencies>
    <dependency>
        <groupId>com.abc.proj</groupId>
        <artifactId>commons</artifactId>
        <version>0.1</version>
    </dependency>
  </dependencies>
  
</project>

In xyz Module I added commons dependency.

When I run mvn clean install in order to builds all the modules. xyz module is failing because it not able to resolve the package of from commons jar.

I tried running mvn dependency:list I am able to see the common jars in xyz module.

I commented all the classes in xyz and tried to build it once. I was able ti build successfully and when i extracted xyz-01.jar, I found that, it contains commons jar in it. But still not able to resolve the package.

Any idea or help?

  • Hello and welcome. Please don't indent the first line of each paragraph. It messes up the formatting. Also, generally, please go easy on the formatting and avoid superfluous blockquotes (`>`) and **strong** text. – Federico klez Culloca Sep 29 '22 at 08:05
  • First you should check your build via `mvn clean verify` ... `mvn clean install` can hide some issues... furthermore it would be helpful to really see the failing output messages... – khmarbaise Sep 29 '22 at 08:17
  • /Users/git/abc/xyz/src/main/java/com/abc/proj/xy/service/impl/CSTV2Service.java:[16,44] error: package com.abc.proj.commons.auth.accessor does not exist – user20117605 Sep 29 '22 at 08:44
  • Where are you running the maven command? In parent or in xyz? – pringi Sep 29 '22 at 08:53
  • I have tried in both parent and xyz – user20117605 Sep 29 '22 at 10:31

0 Answers0