关于 HotSwappableTargetSource 用法的疑问!
因为公司项目要求登陆时能切换数据源,所以使用了HotSwappableTargetSource这个类,现在问题是根本没办法切换数据源,不知道错在哪了,各位帮我看看:
配置文件:
<bean id= "dataSource " class= "org.apache.commons.dbcp.BasicDataSource ">
<property name= "driverClassName ">
<value> ${datasource.driverClassName} </value>
</property>
<property name= "url ">
<value> ${datasource.url} </value>
</property>
<property name= "username ">
<value> ${datasource.username} </value>
</property>
<property name= "password ">
<value> ${datasource.password} </value>
</property>
</bean>
<bean id= "dataSource1 " class= "org.apache.commons.dbcp.BasicDataSource ">
<property name= "driverClassName ">
<value> ${datasource.driverClassName} </value>
</property>
<property name= "url ">
<value> ${datasource.url1} </value>
</property>
<property name= "username ">
<value> ${datasource.username} </value>
</property>
<property name= "password ">
<value> ${datasource.password} </value>
</property>
</bean>
<bean id= "swappableDataSource " class= "org.springframework.aop.target.HotSwappableTargetSource ">
<constructor-arg>
<ref local= "dataSource "/>
</constructor-arg>
</bean>
<bean id= "swappable " class= "org.springframework.aop.framework.ProxyFactoryBean ">
<property name= "targetSource ">
<ref local= "swappableDataSource "/>
</property>
</bean>
<!-- Hibernate SessionFactory -->