vendredi 24 juin 2011

Comment ajouter log4j dabs une application Spring3 Maven avec JBoss6 ?

Pour ajouter log4j avec Maven, on a tendance à faire :

<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.15</version>
</dependency>

Or la compilation va échouer en raison de la license des artefacts utilisé pour certaines fonctionnalités dans log4j.
J'ai trouvé cet explication sur le blog suivant : http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

If you’re using Maven to manage your project’s build and dependencies, you may have encountered some problems when trying to include the latest version of log4j as a dependency.
 Specifically, log4j 1.2.15 depends on some artifacts that are not available in the central Maven repository due to licensing issues, and thus when you try to build a project that depends on this version of log4j,
 you may not be able to download the artifacts and your build will fail.

Donc pour que cela fonctionne, il faut exclure certaines dépendances :
   <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.15</version>
     <exclusions>
       <exclusion>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
       </exclusion>
       <exclusion>
         <groupId>javax.jms</groupId>
         <artifactId>jms</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jdmk</groupId>
         <artifactId>jmxtools</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jmx</groupId>
         <artifactId>jmxri</artifactId>
       </exclusion>
     </exclusions>
   </dependency>

J'ai committé l'ajout de log4j dans le trunk de mon projet tutoriel sur Spring Maven et JBoss 6 : http://code.google.com/p/lin-mon-webapp/

references :
http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

Aucun commentaire:

Enregistrer un commentaire