I\'m trying to setup a webapp with maven2 managed dependcies. Here my pom.xml
Hibernate depends on slf4j-api, so you need to add missing dependency in you pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta4</version>
</dependency>
You are missing
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
This should indeed work, the slf4j-log4j12 binding contains org/slf4j/impl/StaticLoggerBinder
.
Some unrelated remarks:
Instead of repeating frameworks version in dependencies, you should use a property. For example:
...
<properties>
<spring.version>3.0.2.RELEASE</spring.version>
...
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
...
</dependencies>
hibernate-core
is a transitive dependency of hibernate-annotations
, you don't need to declare it (if you want to use JPA, you should actually depend on hibernate-entitymanager
).
Hibernate depends on slf4j-api, so declaring it yourself shouldn't make any difference. Apart from that, I don't know why it's not working.
Include the slf4j-api in your dependencies:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
Exclude the commons-logging dependency for minimum one of your declared spring dependencies and provide the slf4j facade for commons-logging:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
Include the log4j dependency for your logging together with the slf4j facade:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
A great blog post for further reading about logging with SLF4J and Spring can be found in the SpringSource Team blog under http://blog.springsource.com/2009/12/04/logging-dependencies-in-spring/.