Solved

How to Control Maven Dependency Order in Different Modules

Posted on 2011-09-09
5
305 Views
Last Modified: 2012-06-27
I have a program where I have the same java method at two  different locations. I have a java class, e.g., public class foo located "jiatfw-core "or Module B, I also have this same class (foo) located in module "core" or Module C. I am running my main class from a module called "jiatfw-bl" or Module A.

My problem is that my Module A is using the code in Module C or "core" where the class was originally defined, but I want it to use the class located in Model B or "jiatfw-core" which overrides the methods used in the base core.

Below is a cutout of my POM file located in module A or "jiatfw-bl".

I believe that which ever dependency is defined first is used first. Identical to defining different classes in a java classPath statement.

Can someone suggest to me what I might be doing wrong. Attached is a graph showing the relationship between modules.

    <parent>
        <artifactId>jiatfw-parent</artifactId>
        <groupId>com.inc.jiatfw</groupId>
        <version>1-SNAPSHOT</version>
    </parent>

    <artifactId>jiatfw-bl</artifactId>
    <name>JIATFW BL</name>

    <dependencies>
        <dependency>
            <groupId>com.inc.jiatfw</groupId>
            <artifactId>jiatfw-core</artifactId>
            <version>1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.inc.components.core</groupId>
            <artifactId>core</artifactId>
        </dependency>
dependency.PNG
0
Comment
Question by:Cedarville
  • 3
  • 2
5 Comments
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 500 total points
ID: 36513517
And both classes foo have the same fully qqualifies name with packages, etc.
So you have two copies of the same package jiatfw-core and the same pacjkage in core ?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36513539
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36513578
You probably have later version of maven than 2.0.9, as as you see from the above link, before
the ordr was not specified deterministicallly
0
 

Accepted Solution

by:
Cedarville earned 0 total points
ID: 36514178
First, to answer your question for_yan. Yes, everthing is the same as far as package name and class/method name. I think the method signatures are different.

I will check out the link you specified.


Thankyou,
Cedarville
0
 

Author Closing Comment

by:Cedarville
ID: 36553549
Answer did not help, but I appreciate the effort
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now