des problèmes avec applicationContext.xml, la configuration de Hibernate, Spring MVC, et MySql

Je suis en train de configuration de spring mvc 3.0 + Hibernate + MySql avec Maven.
Ayant des problèmes frustrants avec l'applicationContext.xml.
Le contrôleur au service de la DAO travaux, juste que je vais avoir des problèmes de configuration d'Hibernate pour MySql.

Googlé beaucoup de choses en ligne, mais les différents tutoriels ont des instructions différentes, donc je suis tout foiré maintenant.

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<context:component-scan base-package="com.ray.service.blog" />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean id="blogDao" class="com.ray.service.blog.dao.BlogDao">
<!-- <property name="sessionFactory" ref="sessionFactory"></property> -->
<constructor-arg ref="sessionFactory" />
</bean>
<bean id="blogService" class="com.ray.service.blog.services.BlogService" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/ray" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>

Voici les premières lignes de la trace de la pile:

[2012-01-04 10:17:27,265] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.ray.service.blog.controllers.BlogController.setBlogService(com.ray.service.blog.services.BlogService); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.ray.service.blog.services.BlogService.setBlogDao(com.ray.service.blog.dao.BlogDao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)

Laissez-moi savoir si vous avez besoin de plus d'informations... merci!

InformationsquelleAutor gruuuvy | 2012-01-04