MyBatis Spring整合配置映射接口类与映射xml文件
来源:互联网 发布:淘宝店铺 武汉飞鱼运动 编辑:程序博客网 时间:2024/05/17 01:40
<?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:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd ">
<!-- spring 整合mybatis配置映射接口类和映射xml文件 -->
<!-- 加载db.properties文件中的内容,db.properties文件中key命名要有一定的特殊规则 -->
<context:property-placeholder
location="classpath:db.properties,classpath:redis.properties" />
<!-- 配置数据源 ,dbcp -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 数据库连接池 -->
<property name="dataSource" ref="dataSource" />
<!-- 加载mybatis的全局配置文件 -->
<property name="configLocation" value="classpath:mybatis/mybatis.xml" />
</bean>
<!-- mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 扫描包路径,如果需要扫描多个包,中间使用半角逗号隔开 -->
<property name="basePackage" value="com.huayu.volleyball.*.mapper"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<!-- redis配置 -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.pool.maxIdle}" />
<property name="maxWaitMillis" value="${redis.pool.maxWait}" />
<!-- <property name="" value="${redis.pool.maxActive}" /> -->
<property name="testOnBorrow" value="${redis.pool.testOnBorrow}"></property>
</bean>
<!-- redis服务器中心 -->
<bean id="connectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:hostName="${redis.pool.addrArray}" p:port="${redis.pool.port}"
p:timeout="${redis.pool.timeout}" p:poolConfig-ref="poolConfig" />
<!-- <bean id="stringSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/> -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultSerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
</bean>
<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:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd ">
<!-- spring 整合mybatis配置映射接口类和映射xml文件 -->
<!-- 加载db.properties文件中的内容,db.properties文件中key命名要有一定的特殊规则 -->
<context:property-placeholder
location="classpath:db.properties,classpath:redis.properties" />
<!-- 配置数据源 ,dbcp -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 数据库连接池 -->
<property name="dataSource" ref="dataSource" />
<!-- 加载mybatis的全局配置文件 -->
<property name="configLocation" value="classpath:mybatis/mybatis.xml" />
</bean>
<!-- mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 扫描包路径,如果需要扫描多个包,中间使用半角逗号隔开 -->
<property name="basePackage" value="com.huayu.volleyball.*.mapper"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<!-- redis配置 -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.pool.maxIdle}" />
<property name="maxWaitMillis" value="${redis.pool.maxWait}" />
<!-- <property name="" value="${redis.pool.maxActive}" /> -->
<property name="testOnBorrow" value="${redis.pool.testOnBorrow}"></property>
</bean>
<!-- redis服务器中心 -->
<bean id="connectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:hostName="${redis.pool.addrArray}" p:port="${redis.pool.port}"
p:timeout="${redis.pool.timeout}" p:poolConfig-ref="poolConfig" />
<!-- <bean id="stringSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/> -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultSerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
</bean>
阅读全文
0 0
- MyBatis Spring整合配置映射接口类与映射xml文件
- MyBatis Spring整合配置映射接口类与映射xml文件
- MyBatis Spring整合配置映射接口类与映射xml文件
- MyBatis Spring整合配置映射接口类与映射xml文件
- MyBatis Spring整合配置映射接口类与映射xml文件
- MyBatis Spring整合配置映射接口类与映射xml文件
- spring+mybatis整合,不需要配置映射文件,多路径配置
- mybatis逆向生成实体类,接口类,映射xml文件
- mybatis 生成映射文件generatorConfig.xml配置
- mapper.xml映射文件配置 mybatis
- Mybatis XML映射文件
- Mybatis--XML映射文件
- mybatis 分页查询 内含有测试类实体类映射文件与映射接口
- 使用spring整合mybatis时映射文件的导入方法
- maven下 spring+springmvc+mybatis整合,映射文件加载异常
- MyBatis的XML映射文件、映射器
- Spring、MyBatis的整合数据映射器类(UserMapper->iocContext.xml)配置文件详解
- 整合maven+mybatis+generator生成java自定义model实体类,dao接口和mapper映射文件
- centos 使用mail发送邮件
- C# 中的委托和事件
- 文章标题
- Comet工作原理
- SpringBoot使用教程【1】Restful API设计 返回json,xml格式
- MyBatis Spring整合配置映射接口类与映射xml文件
- Android 内置google dialer后发现拨号后,没有通话界面显示。
- SolrCloud详解及搭建
- MySQL中的锁(表锁、行锁,共享锁,排它锁,间隙锁)
- C语言如何不用goto、多处return进行错误处理?
- easyui-combobox
- 关闭Android jack 编译
- amultiple-column index
- 009