日期:2014-05-17 浏览次数:20671 次
<!-- 加载数据源配置文件 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:data-source.properties </value> </list> </property> </bean> <!-- 定义 CP平台mysql数据源 --> <bean id="xxSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${xx_DriverClassName}" /> <property name="url" value="${xx_url}" /> <property name="username" value="${xx_username}" /> <property name="password" value="${xx_password}" /> <property name="initialSize" value="${xx_initialSize}" /> <property name="maxActive" value="${xx_maxActive}" /> <property name="maxWait" value="${xx_maxWait}" /> <property name="maxIdle" value="${xx_maxIdle}" /> <property name="minIdle" value="${xx_minIdle}" /> <property name="removeAbandoned" value="${xx_removeAbandoned}" /> <property name="removeAbandonedTimeout" value="${xx_removeAbandonedTimeout}" /> </bean> <!-- 为每个数据源单独定义 SqlSessionFactory --> <bean id="xxSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="xxSource" /> </bean> <!-- 为每个数据源单独定义 SqlMapper --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="路径1,路径2" /> <property name="sqlSessionFactory" ref="xxSqlSessionFactory" /> </bean>
------解决方案--------------------