-3

Pom.xml have this elements and I am curious why do we need exclude commons-logging from spring-core? And how do it works?

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.0.5.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>
<!-- next is log4j dependencie -->
rozero
  • 149
  • 3
  • 15

3 Answers3

0

I have seen and done the similar things before, the reason is simple:

To exclude commons-logging library because I want to use log4j instead.

So you tell maven to not include the unnecessary library, and to do that use < exclusion >.

OPK
  • 4,120
  • 6
  • 36
  • 66
0

You are probably using a different version of commons-logging in your program than the one that is defined by spring-core 3.0.5.RELEASE. Check the dependecies of your program and see if there is another commons-logging defined.

JFPicard
  • 5,029
  • 3
  • 19
  • 43
0

In the example above spring-core itself has a dependency on commons-logging so it will pull that jar into the project. For what ever reason the user did not want the commons-logging that comes with spring-core, they may want to use another version.

It is possible to have 2 dependencies which have sub dependencies that clash with each other, although I would say this is rare. Usually excludes can be used sparingly.

Essex Boy
  • 7,565
  • 2
  • 21
  • 24