Nov 10th, 2010, 12:24 AM
Simpler way to exlude commons-logging in Spring
Chapter 1 of the Spring documentation, more precisely section 22.214.171.124, describes a strategy of replacing commons-logging with slf4j. The described strategy uses maven exclusions. I think a considerably simpler and more robust strategy is to declare commons-logging in the provided scope. The actual commons-logging classes would be provided by jcl-over-slf4j. This translates into the following pom file snippet:
The first dependency declaration essentially states that commons-logging will be "somehow" provided by the user's environment. The second declaration includes jcl-over-slf4j into your project. As jcl-over-slf4j is a perfect binary-compatible replacement for commons-logging, the first assertion becomes true.
This approach covers all dependencies using commons-logging with just one declaration whereas with the explicit exclusion approach commons-logging needs to be explicitly excluded in every dependency depending on common-logging.
Last edited by Ceki Gülcü; Nov 10th, 2010 at 12:28 AM.
Tags for this Thread