spring-boot + Ehcache without XML
http://stackoverflow.com/questions/21944202/using-ehcache-in-spring-4-without-xml
1、Ehcache配置类
@Configuration
@EnableCaching
public class CachingConfig implements CachingConfigurer {
@Bean(destroyMethod="shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName("myCacheName");
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.setMaxEntriesLocalHeap(1000); net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
config.addCache(cacheConfiguration); return net.sf.ehcache.CacheManager.newInstance(config);
} @Bean
@Override
public CacheManager cacheManager() {
return new EhCacheCacheManager(ehCacheManager());
} @Bean
@Override
public KeyGenerator keyGenerator() {
return new SimpleKeyGenerator();
}
}
2、调试简单配置类
@Configuration
@EnableCaching
public class CachingConfig implements CachingConfigurer {
@Bean
@Override
public CacheManager cacheManager() {
SimpleCacheManager cacheManager = new SimpleCacheManager(); List<Cache> caches = new ArrayList<Cache>();
caches.add(new ConcurrentMapCache("myCacheName"));
cacheManager.setCaches(caches); return cacheManager;
} @Bean
@Override
public KeyGenerator keyGenerator() {
return new SimpleKeyGenerator();
}
}
spring-boot + Ehcache without XML的更多相关文章
- Spring boot 配置 mybatis xml和动态SQL 分页配置
更新时间 2018年4月30日23:27:07 1.pom.xml <?xml version="1.0" encoding="UTF-8"?> & ...
- Spring Boot中扩展XML请求和响应的支持
在Spring Boot中,我们大多时候都只提到和用到了针对HTML和JSON格式的请求与响应处理.那么对于XML格式的请求要如何快速的在Controller中包装成对象,以及如何以XML的格式返回一 ...
- spring boot(14)-pom.xml配置
继承spring-boot-starter-parent 要成为一个spring boot项目,首先就必须在pom.xml中继承spring-boot-starter-parent,同时指定其版本 & ...
- spring boot的pom.xml配置,正确生成jar包
spring boot生成的jar包提示没有主清单属性. 需要在pom里加入配置. <?xml version="1.0" encoding="UTF-8" ...
- Spring Boot (15) pom.xml设置
继承spring-boot-parent 要成为一个spring boot项目,首先就必须在pom.xml中继承spring-boot-starter-parent,同时制定其版本 <paren ...
- spring boot系列(六)spring boot 配置mybatis(xml简化版)
orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,一个是宣称可以不用写一句SQL的hibernate,一个是可以灵活调试动态sql的mybatis,两者各有特点,在企业级系统开 ...
- Spring boot 配置 log4j2.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- SpringBoot零XML配置的Spring Boot Application
Spring Boot 提供了一种统一的方式来管理应用的配置,允许开发人员使用属性properties文件.YAML 文件.环境变量和命令行参数来定义优先级不同的配置值.零XML配置的Spring B ...
- [Spring boot] web应用返回jsp页面
同事创建了一个spring boot项目,上传到svn.需要我来写个页面.下载下来后,始终无法实现在Controller方法中配置直接返回jsp页面. 郁闷了一下午,终于搞定了问题.在此记录一下. 目 ...
- 【原】spring boot在整合项目依赖的问题
最近要开发新的项目,就花了几天时间看了下spring boot的相关资料,然后做了一个demo,不得不说开发效率确实很快,几行注解就完成了事务,aop,数据库等相关配置:但由于先前习惯了spring ...
随机推荐
- IoSkipCurrentIrpStackLocation .(转)
原文链接:http://m.blog.csdn.net/blog/ruanben/19758769# 当驱动被分层以后,他们被注册到一个chain中,IRP会在这个chain中传递,从最上面,到最下面 ...
- windows7 ubuntu双系统采用windows7 mbr引导方法
在安装有Windows7系统上的机器,安装用Ubuntu后,开机会自动用grub2 引导.对于使用双系统的用户来说,用MBR和grub2都差不多,但是,我的机器上有三个系统,需要用MBR来引导变色龙, ...
- GCC编译源代码的四个步骤【转】
GCC编译C源代码有四个步骤:预处理---->编译---->汇编---->链接. 可以利用GCC的参数来控制执行的过程,这样就可以更深入的了解编译C程序的过程. 下面将通过对一个程序 ...
- 解决OpenCV Error:Insufficient memory(Failed to allocate 1244164 bytes) in unknown function
从师兄那拷贝过来的代码,师兄的机器上可以运行,环境为Win7+OpenCV231,编译器为Debug Win32,拷贝到自己机器上运行时出现问题. 本机的运行环境为win10+OpenCV244,编译 ...
- HDU-4611 Balls Rearrangement 循环节,模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4611 先求出循环节,然后比较A和B的大小模拟过去... //STATUS:C++_AC_15MS_43 ...
- 多进程解决datasnap支持的tcp长连接数量少的问题
对于实时采集数据的项目,应用场景比如是这样的:5000客户端,每个客户端每隔500MS要给服务器上传一次数据. 大家知道,像INDY这种阻塞型的通信控件,所能支持的TCP长连接的一般地不能超过1000 ...
- 第1组UI组件:布局管理器
1 布局管理的来源 为了让UI在不同的手机屏幕上都能运行良好----不同手机屏幕的分辨率/尺寸并不完全相同,如果让程序手动控制每个组件的大小.位置,会给编程带来巨大的麻烦.为了解决这个问题.andro ...
- PTA 5-15 PAT Judge (25分)
/* * 1.主要就用了个sort对结构体的三级排序 */ #include "iostream" #include "algorithm" using nam ...
- nginx+tomcat+redis负载均衡及session共享
概述 本文档是用来详细描述 nginx+tomcat+redis负载均衡实现session共享 所需软件及下载地址 软件名称 下载地址 功能说明 Nginx-v1.6.0 http://nginx.o ...
- GridView控件显示图片
与图片的二进制数据库存储和显示 1.将图片以二进制存入数据库 2.读取二进制图片在页面显示 3.设置Image控件显示从数据库中读出的二进制图片 4.GridView中ImageField以URL方式 ...