Ignore transitive dependency in Maven


Maven helps to manage the dependency of JARS . Most of the time it may happen that same JAR file with different versions is being loaded because some other jar files have it as dependency and thus causing the conflicts .

Typical example is have log4j or slf4j jar with different version in spring-xx.jar and junit-xxx.jar . So when you load you classes an conflict may arise and because of incompatible version of same jar file . For e.g.

<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-core</artifactId>
	<version>3.2.1.RELEASE</version>
</dependency>

The above jar uses log4j 1.2.17 (you can check the dependency using mvn dependency:tree).

Consider this log4j jar file is conflicting with some other higher version of log4j which is used by other jar. To resolve this issue we would have to remove the conflicting log4j jar from org.springframework.
it can be done as follows :

<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-core</artifactId>
	<version>3.2.1.RELEASE</version>
         <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
</dependency>

Cheers..

Advertisements

29 thoughts on “Ignore transitive dependency in Maven

  1. It is able to support numerous numbers of windowpane versions. There are even a few generators that are run by pedal power- you petal a stationary bike to produce power but these do not power large items. If you don’t have the points in Science, you can then go to the other computer inside the bunker to the right.

  2. You really make it seem really easy along with your presentation however I in finding this topic to be actually one thing that I think I’d never understand. It kind of feels too complex and very vast for me. I’m having a look forward in your subsequent submit, I’ll attempt to get the hold of it!

  3. Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is totally off topic but I had to tell someone!

  4. I like the valuable information you provide in your articles. I’ll bookmark your blog and check again here frequently. I’m quite certain I’ll learn a lot of new stuff right here! Best of luck for the next!

  5. I don’t know whether it’s just me or if everybody else encountering issues with your site. It looks like some of the text within your posts are running off the screen. Can someone else please provide feedback and let me know if this is happening to them as well? This could be a problem with my internet browser because I’ve had this happen before. Thanks

  6. I was curious if you ever considered changing the structure of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or 2 pictures. Maybe you could space it out better?

  7. I’m more than happy to uncover this site. I need to to thank you for your time due to this wonderful read!! I definitely savored every bit of it and I have you saved as a favorite to look at new things on your web site.

  8. This is the perfect webpage for anybody who wants to find out about this topic. You understand so much its almost hard to argue with you (not that I really would want to…HaHa). You certainly put a fresh spin on a subject that has been discussed for years. Great stuff, just excellent!

  9. It’s really a nice and useful piece of information. I am glad that you shared this helpful information with us. Please stay us up to date like this. Thanks for sharing.

  10. Greetings from Carolina! I’m bored to tears at work so I decided to check out your site on my iphone during lunch break. I love the knowledge you provide here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my cell phone .. I’m not even using WIFI, just 3G .. Anyhow, awesome site!

  11. When company is very specific regarding needs, commemorate our responsibility less difficult to make sure they’re happy. Your guest just confirms what we already knew; which they would perceive this ultimate satisfying experience for a luxury health club worth the cost as well as more. In order to view the chi stream of meridians in the body system, the practitioner must move toward a deep subconscious transfer of understanding for many people years.

  12. Unquestionably believe that that you stated. Your favorite justification appeared to be on the internet the easiest thing to remember of. I say to you, I definitely get annoyed even as other people think about worries that they just do not recognise about. You managed to hit the nail upon the highest and defined out the whole thing with no need side effect , other people could take a signal. Will likely be again to get more. Thank you

  13. You are so awesome! I do not believe I’ve read through a single thing like that before. So wonderful to discover someone with original thoughts on this subject matter. Really.. thank you for starting this up. This website is something that’s needed on the internet, someone with some originality!

  14. Hey There. I discovered your blog the usage of msn. This is a really neatly written article. I’ll make sure to bookmark it and come back to learn extra of your useful info. Thank you for the post. I will certainly return.

  15. That is a very good tip especially to those fresh to the blogosphere. Short but very precise information… Appreciate your sharing this one. A must read article!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s