Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

java - Maven: Project A not respecting Project B's exclusion

I have two projects A, and B.

Project A depends on Project B. Project B depends on a library C which depends on a library D. I own both A and B but they live in separate code bases and are independent. Project B is like an internal common helper library.

- A 
-- B 
--- C (version 1.1)
---- D (version 1.1)

I want to upgrade D to a newer minor version, let's say 1.5.

So in B's pom.xml file, I imported D (v1.5) directly. Then excluded D from C. Example:


Next if I run

[~/projectB] $ mvn dependency:tree

I confirm that only 1.5 is used, not 1.1. Next I build a new local snapshot of B. And specify Project A to use that one.

My problem is when I build Project A, it continues to use v1.1 and ignores the exclusion in B. This always returns 1.1 instead of the 1.5 that I want.

[~/projectA] $ mvn dependency:tree

Project A never imports C or D directly, it only get library D from importing Project B.

I've tried:

  • Reloading the maven imports
  • Running mvn clean install numerous times.
  • Deleting the folders from my .m2/ directory to force reimports

I'm out of troubleshooting ideas. Does anyone else have any tips?

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share