mybatis注解配置缓存的方法
来源:互联网 发布:mysql左外连接查询 编辑:程序博客网 时间:2024/06/05 01:59
mapper文件
package it.com.db;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.cache.decorators.LruCache;
import com.mysql.jdbc.util.LRUCache;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
@CacheNamespace(
size=100,eviction=LruCache.class,implementation=org.mybatis.caches.ehcache.EhcacheCache.class)
public interface IuserMapper {
@Select("select * from username")
@Options(useCache=true)
public List<Map> findAll();
}
conf文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="true"></setting>
</settings>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<!-- 配置数据库连接信息 -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/luntan" />
<property name="username" value="root" />
<property name="password" value="mysql" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper class="it.com.db.IuserMapper"/>
</mappers>
</configuration>
ehcache.xml文件
<ehcache>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
log4j.properties 文件
### ÉèÖÃLoggerÊä³ö¼¶±ðºÍÊä³öÄ¿µÄµØ ###
log4j.rootLogger = all, stdout,logfile
### °ÑÈÕÖ¾ÐÅÏ¢Êä³öµ½¿ØÖÆ̨ ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
### °ÑÈÕÖ¾ÐÅÏ¢Êä³öµ½Îļþ£ºjbit.log ###
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=d\:\\tt.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%l %F %p %m%n
IuserMapper文件
package it.com.db;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.cache.decorators.LruCache;
import com.mysql.jdbc.util.LRUCache;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
@CacheNamespace(
size=100,eviction=LruCache.class,implementation=org.mybatis.caches.ehcache.EhcacheCache.class)
public interface IuserMapper {
@Select("select * from username")
@Options(useCache=true)
public List<Map> findAll();
}
- mybatis注解配置缓存的方法
- MyBatis的缓存配置(Cache)
- mybatis缓存文件的配置
- spring4配置基于注解的ehcache缓存
- 基于注解配置简单的SpringMVC+Mybatis
- 注解(Annotation)方法的MyBatis
- mybatis的二级缓存--配置redis缓存
- MyBatis自带的缓存配置(Cache)
- mybatis 注解配置
- mybatis配置mapper注解
- Mybatis使用 注解配置
- mybatis使用注解编写crud后,不配置mapping方法。
- spring整合mybatis完整案例(注解配置方法)
- mybatis的缓存配置--ehcache.xml(缓存配置文件)
- Mybatis配置缓存
- MyBatis缓存配置
- Mybatis redis 缓存配置
- MyBatis缓存配置
- Andriod ListView
- Windows7(32位)下安装Ubuntu16.04双系统
- 工厂方法模式
- 微信支付回调处理
- 近期目标
- mybatis注解配置缓存的方法
- SQL--索引
- oracle varchar2与varchar的区别
- python 学习笔记4
- zoj分类
- MyEclipse 安装Gardle环境
- Wamp &ThinkPHP 环境下PHP5 连接Oracle12c 步骤
- keil输出hex文件
- windows系统设置环境变量,系统变量