Bonjour,
Je développe une applciation Spring MVC/Hibernate/Mysql
Au démarrage de Tomcat j'ai cette erreur :
Il ne trouve pas le bean référencé idDataSource, mais j'ai pourtant bien défini idDataSource comme bean (cf code ci dessous).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Cannot resolve reference to bean 'idDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'idDataSource' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition
Savez vous pourquoi j'ai cette erreur?
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
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 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation=" 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"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <!-- Imports user-defined @Controller beans that process client requests --> <beans:import resource="controllers.xml" /> <beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <beans:property name="dataSource" ref="idDataSource"/> <beans:property name="hibernateProperties"> <beans:props> <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop> <beans:prop key="hibernate.show_sql">true</beans:prop> </beans:props> </beans:property> <beans:property name="annotatedClasses"> <beans:list> <beans:value>com.thomas.tutorial</beans:value> </beans:list> </beans:property> </beans:bean> <beans:bean id="idDataSource"> <beans:property name="jdbc.driverClassName" value="com.mysql.jdbc.Driver"></beans:property> <beans:property name="jdbc.url" value="jdbc:mysql://localhost:3306/devis"></beans:property> <beans:property name="jdbc.username" value="root"></beans:property> <beans:property name="jdbc.password" value="root"></beans:property> </beans:bean> </beans:beans>
Partager