ssm 连接两个数据库

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans  
                        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
                        http://www.springframework.org/schema/context  
                        http://www.springframework.org/schema/context/spring-context-4.0.xsd  
                        http://www.springframework.org/schema/mvc  
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
	<!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->
	<context:component-scan base-package="com.cn.eport.controller" />
	<!--避免IE执行AJAX时,返回JSON出现下载文件 -->
	<bean id="mappingJacksonHttpMessageConverter"
		class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/html;charset=UTF-8</value>
			</list>
		</property>
	</bean>

	<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<ref bean="mappingJacksonHttpMessageConverter" />	<!-- JSON转换器 -->
			</list>
		</property>
	</bean>

	<!-- 视图解析器配置 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
	
	
	<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->
	<bean id="multipartResolver"  
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
        <!-- 默认编码 -->
        <property name="defaultEncoding" value="utf-8" />  
        <!-- 文件大小最大值 -->
        <property name="maxUploadSize" value="10485760000" />  
        <!-- 内存中的最大值 -->
        <property name="maxInMemorySize" value="40960" />  
    </bean> 
    	<!-- <mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/" />
			<mvc:mapping path="/**" />
			<bean class="com.cn.eport.interceptor.CommonInterceptor"></bean>
		</mvc:interceptor>
	</mvc:interceptors> -->
</beans>

  

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans  
                        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
                        http://www.springframework.org/schema/context  
                        http://www.springframework.org/schema/context/spring-context-4.0.xsd  
                        http://www.springframework.org/schema/mvc  
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
	<!-- 自动扫描 -->
	<context:component-scan base-package="com.cn.eport" />
	
	<!-- 引入配置文件 -->
	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:jdbc.properties" />
	</bean>
   <!-- ERPOT数据源 -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${eport.jdbc.driver}" />
		<property name="url" value="${eport.jdbc.url}" />
		<property name="username" value="${eport.jdbc.username}" />
		<property name="password" value="${eport.jdbc.password}" />
		<!-- 初始化连接大小 -->
		<property name="initialSize" value="${eport.jdbc.initialSize}"></property>
		<!-- 连接池最大数量 -->
		<property name="maxActive" value="${eport.jdbc.maxActive}"></property>
		<!-- 连接池最大空闲 -->
		<property name="maxIdle" value="${eport.jdbc.maxIdle}"></property>
		<!-- 连接池最小空闲 -->
		<property name="minIdle" value="${eport.jdbc.minIdle}"></property>
		<!-- 获取连接最大等待时间 -->
		<property name="maxWait" value="${eport.jdbc.maxWait}"></property>
	</bean>

	<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- 自动扫描mapping.xml文件 -->
		<property name="mapperLocations" value="classpath:com/cn/eport/mapping/*.xml"></property>
	</bean>

	<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.cn.eport.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>
	
	<!-- 自动扫描 -->
	<context:component-scan base-package="com.cn.ipms" />
	<!-- *************************************IPMS数据源 -->
	<bean id="dataSourceIPMS" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${ipms.jdbc.driver}" />
		<property name="url" value="${ipms.jdbc.url}" />
		<property name="username" value="${ipms.jdbc.username}" />
		<property name="password" value="${ipms.jdbc.password}" />
		<!-- 初始化连接大小 -->
		<property name="initialSize" value="${ipms.jdbc.initialSize}"></property>
		<!-- 连接池最大数量 -->
		<property name="maxActive" value="${ipms.jdbc.maxActive}"></property>
		<!-- 连接池最大空闲 -->
		<property name="maxIdle" value="${ipms.jdbc.maxIdle}"></property>
		<!-- 连接池最小空闲 -->
		<property name="minIdle" value="${ipms.jdbc.minIdle}"></property>
		<!-- 获取连接最大等待时间 -->
		<property name="maxWait" value="${ipms.jdbc.maxWait}"></property>
	</bean>

	<!-- 事务管理器spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
	<bean id="sqlSessionFactoryIPMS" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSourceIPMS" />
		<!-- 自动扫描mapping.xml文件 -->
		<property name="mapperLocations" value="classpath:com/cn/ipms/mapping/*.xml"></property>
	</bean>
	<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.cn.ipms.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryIPMS"></property>
	</bean>
	
</beans>

  

eport ipms两个数据库

  

猜你喜欢

转载自www.cnblogs.com/ynhk/p/10413900.html