一、在POM中添加相关的库包引用:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
二、添加ehcache的配置:ehcache.xml
<ehcache updateCheck="true" name="application-cache">
<diskStore path="java.io.tmpdir"/>
<defaultCache maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU" />
</ehcache>
三、在spring配置文件 application-context.xml中添加配置:
beans头中添加引用:
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation中添加
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
添加ehcache的bean:
<cache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cacheManager-ref="ehcache"/>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache.xml" p:shared="true"/>
四、修改mybatis-config.xml:
添加:
<!-- 全局映射器启用缓存 -->
<setting name="cacheEnabled" value="true"/>
该步骤也可以省略,mybatis默认cacheEnable是打开的
五、在需要使用缓存的mapper中添加:
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
<!--<cache type="org.mybatis.caches.ehcache.EhcacheCache"/>-->
实测中没发现这两者有什么区别。相关资料说LogginEhcache打开了日志。
分享到:
相关推荐
本后台管理系统,采用流行的框架springMvc+spring+mybatis+shiro+redis+ehcache开发,实现了权限管理(菜单权限、数据权限),solr全文搜索引擎,activiti工作流程引擎,cas单点登陆等功能,完善的代码生成器 后期还...
积分最低,Spring MVC+Mybatis+Ehcache+Apache Shiro+Bootstrap整合开发java仓库管理系统源码 开发环境:Eclipse ,JDK 1.8 ,Tomcat7 技术选型 后端技术 SpringMVC MVC框架 Spring Framework 容器 Apache ...
SpringMVC+Mybatis+Spring+Shiro+ehcache整合配置文件
Spring4 SpringMVC MyBatis 模板引擎beetl 前端bootstrap 数据源druid 缓存ehcache MyBatis分页插件PageHelper MyBatis通用Mapper 源码完整+带sql脚本+亲测可以用,而且功能很强大,是一个完善的框架实例。
不是基于maven,项目中包含所有代码及其jar包,下载即可运行,spring为4.0以上,如果你本地jdk为1.7有可能会出现问题,修改jdk为1.8以上即可
主要介绍了JavaWeb开发之Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架的相关资料,需要的朋友可以参考下
springMVC3.2.5+mybatis3.2.5+shiro+easyui1.4.2+ehcache
1.标题所提及技术的整合,Spring包括mvc、aop、ioc等。个人属于强迫症类型,技术水平怎么样再说,代码必须好看 2.Hibernate几个级别缓存对比。见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache...
此项目为springmvc、Mybatis、EHcache、maven、Spring security3、activiti5工作流的整合 是一个基于数据库的权限管理demo项目、使用mysql数据库 项目运行前需要构建maven私服 而且有些jar包私服中肯定没有,需要...
校友录网站。基于javaWeb,由Maven构建管理,采用Spring+SpringMVC+MyBatis框架,用EhCache做数据缓存。门户网站采用BootStrap设计界面,后台管理网站用AmazeUI设计界面。.zip
整合EhCache,对Mybatis的二级缓存进行管理和对spring进行缓存管理 整合FastJson对指定http类型的数据进行转换 整合hibernate.validator校验器对controller接口参数进行校验 使用了springmvc统一异常处理 使用了...
spring mvc注解方式学习搭建的项目,供大家参考
1.标题所提及技术的整合,Spring包括mvc、aop、ioc等。个人属于强迫症类型,技术水平怎么样再说,代码必须好看 2.Hibernate几个级别缓存对比。见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache...
Spring Framework 容器 Apache Shiro 安全框架 Mybatis ORM框架 MyBatis Generator 代码生成 C3P0 数据库连接池 Ehcache 进程内缓存框架 Apache poi 文件导入导出 Maven 项目构建管理 前端技术 jQuery , ...
spring+ehcache+mabatis。测试用例用的是mysql,数据库的配置在jdbc.properties里面。所要的sql在src/main/resources下的student.sql。测试的话调用controller下的update和getOne那两个接口测试。
本次上传的资源是spring+springMVC+mybatis整合的简单增删查改,有助于初学者在idea软件上操作,其中用到的数据库是mysql,资源里面还整合了spring的ehcache二级缓存。
这是自己整合的Spring 3.0+Struts2+Mybatis 3 + p6spy +ehcache的平台框架,内含一点示例代码,目前ehcache没有使用。直接编译后发布就能用 测试环境基于JDK1.6+Tomcat 6.0. 大家拿到后请根据实际情况修改 ...
基于SpringMVC+Spring+MyBatis (SSM) 架构的高效率便捷开发框架源码+项目说明.zip 本项目是一个整合 **SpringMVC+Spring+MyBatis(SSM)** 框架的 **Demo**。 拥有高效率便捷开发模式,使开发人员更专注于业务,...