Bonjour,
J'ai un problème avec Hibernate et Spring qui est le suivant:
Mon fichier de bean est le suivant:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tester' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is
required
ma classe de test :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN //EN" " http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/dbEstivage</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>Accompagnant.hbm.xml</value> <value>Affectation.hbm.xml</value> <value>Caledrierbs.hbm.xml</value> <value>Calendrierhs.hbm.xml</value> <value>Centre.hbm.xml</value> <value>Choix.hbm.xml</value> <value>Collaborateur.hbm.xml</value> <value>Demande.hbm.xml</value> <value>Demandechoix.hbm.xml</value> <value>Desistementbs.hbm.xml</value> <value>Desistemenths.hbm.xml</value> <value>Fileattente.hbm.xml</value> <value>Logement.hbm.xml</value> <value>Periode.hbm.xml</value> <value>Reservationbs.hbm.xml</value> <value>Role.hbm.xml</value> <value>Typelogement.hbm.xml</value> <value>Typepaiement.hbm.xml</value> <value>Ville.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <!--**** Transaction manager for a single Hibernate SessionFactory (alternative to JTA)****** --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!--**************Data access object: Hibernate implementation.********************--> <bean id="tester" class="service.RoleDaoImpl"> <property name="dao" ref="dao" /> </bean> <bean id="dao" class="dataAcessObject.DaoRoleImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package test; import model.Role; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import service.IRoleDao; import junit.framework.TestCase; public class Tester extends TestCase { static ApplicationContext context; protected void setUp() throws Exception { context = new ClassPathXmlApplicationContext("applicationContext.xml"); } public void test1() { IRoleDao service =(IRoleDao) context.getBean("tester"); Role p = service.getRole(5); p.setLibellerole("user"); service.AddRole(p); }





Répondre avec citation
Partager