Bonjour à tous,
je voudrais mettre deux dataSources dans mon fichier de configuration Spring, je voudrais savoir si c'est possible si oui comment pourrais je le faire.
merci d'avance.





Bonjour à tous,
je voudrais mettre deux dataSources dans mon fichier de configuration Spring, je voudrais savoir si c'est possible si oui comment pourrais je le faire.
merci d'avance.
suffit de declarer 2 dataSources avec des noms differents dans les fichiers de conf de spring.
David Gimelle
Developpeur J2ee
blog: Http://getj2ee.over-blog.com





et dans le sessionFactory je dois mettre mes deux data sources? pourrais tu me donner un exemple.
tu surement va devoir definir 2 sessionFactory.
Est-ce que tu peux montrer ton fichier de config ?
David Gimelle
Developpeur J2ee
blog: Http://getj2ee.over-blog.com





oui biensur:
Code xml : 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 <?xml version="1.0" encoding="UTF-8"?> <!-- Application context for AlimCpt testing --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a> <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a> <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <bean id="anetoVueCotisationEncaissement" class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementImpl"> <property name="anetoVueCotisationEncaissementDAO"> <ref bean="anetoVueCotisationEncaissementDAO" /> </property> </bean> <bean id="anetoVueCotisationEncaissementDAO" class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementDAOImpl"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" /> <property name="username" value="I4UD17_USER" /> <property name="password" value="I4UD17_USER" /> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <!--tx:annotation-driven transaction-manager="txManager"/--> </beans>





j'ai essayé ce que tu m'as dis et ça me donne toujours une exception, voici mon nouveau fichier de conf spring:
Code xml : 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
84
85
86
87
88
89
90
91
92 <?xml version="1.0" encoding="UTF-8"?> <!-- Application context for AlimCpt testing --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a> <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a> <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <bean id="anetoVueCotisationEncaissement" class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementImpl"> <property name="anetoVueCotisationEncaissementDAO"> <ref bean="anetoVueCotisationEncaissementDAO" /> </property> </bean> <bean id="anetoVueCotisationEncaissementDAO" class="com.npfo.comptabilite.business.anetovuecotisationencaissement.AnetoVueCotisationEncaissementDAOImpl"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" /> <property name="username" value="I4UD17_USER" /> <property name="password" value="I4UD17_USER" /> </bean> /******************AnetoVueComptablesCommun*****************/ <bean id="anetovuescomptablescommun" class="com.npfo.comptabilite.business.common.anetovuescomptablescommun.AnetoVuesComptablesCommunImpl"> <property name="AnetoVuesComptablesCommunDao"> <ref bean="AnetoVuesComptablesCommunDao" /> </property> </bean> <bean id="AnetoVuesComptablesCommunDao" class="com.npfo.comptabilite.business.common.anetovuescomptablescommun.AnetoVuesComptablesCommunDaoImpl"> <property name="dataSourceComCom"> <ref bean="dataSourceComCom" /> </property> </bean> <bean id="dataSourceComCom" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@frtlr210.soltim:1521:ANETO51" /> <property name="username" value="I4UD17_OWNER" /> <property name="password" value="I4UD173403" /> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSourceComCom"> <ref bean="dataSourceComCom" /> </property> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <!--tx:annotation-driven transaction-manager="txManager"/--> </beans>
Partager