@ComponentScan(value = "com.gwm")
@Configuration
@EnableCaching
public class SpringConfig {
}
3、引入具体要使用的缓存—实现 Cache 接口
上述 @EnableCaching、@Cacheable 都是 Spring 提供的基本缓存框架,而具体的缓存需要自己引入。比如现在自己定义两个缓存:MyMapCache 类 、MyRedisCache 类。然后实现接口方法。
Spring 提供 Cache 作为标准化接口,具体的实现 Spring 不管,你自己去实现。但是 Spring 也是有几个默认实现的,比如:CaffeineCache、EhCacheCache、ConcurrentMapCache、JCacheCache 等。
public class MyMapCache implements Cache {
public static final Map
MyRedisCache 类实现,代码如下:
public class MyRedisCache implements Cache {
private String cacheName;
private RedisTemplate
4、缓存管理类—实现 CacheManager 接口
自定义缓存定义完之后,光摆在这里肯定是不能起作用的,还需要借助 Spring 标准化接口 CacheManager 类来把缓存加入到缓存切面逻辑中。
比如实现 MyMapCache 缓存管理类 MyMapCacheManager,代码如下:
public class MyMapCacheManager implements CacheManager {
@Override
public Cache getCache(String name) {
return new MyMapCache(name);
}
@Override
public Collection getCacheNames() {
return Arrays.asList("myMapCache");
}
}
实现 MyRedisCache 缓存管理类 MyRedisCacheManager,代码如下:
public class MyRedisCacheManager implements CacheManager {
@Override
public Cache getCache(String name) {
return new MyRedisCache(name,redisTemplate);
}
@Override
public Collection getCacheNames() {
return Arrays.asList("myRedisCache");
}
}
然后在配置入口类中通过 @Bean 引用具体的缓存。代码如下:
@Configuration
public class MyRedisMainConfig {
@Resource
private RedisTemplate redisTemplate;
@Bean
public MyMapCache myMapCache() {
MyMapCache myMapCache = new MyMapCache("myMapCache");
return myMapCache;
}
@Bean
public MyRedisCache myRedisCache() {
MyRedisCache myRedisCache = new MyRedisCache("myRedisCache",redisTemplate);
return myRedisCache;
}
@Bean
public MyRedisCacheManager cacheManager() {
MyRedisCacheManager redisCacheManager = new MyRedisCacheManager();
return redisCacheManager;
}
// @Bean
public MyMapCacheManager cacheManager() {
MyRedisCacheManager redisCacheManager = new MyRedisCacheManager();
return redisCacheManager;
}
}
GetUrlParam:function GetUrlParam(param){
var reg = new RegExp("(^|&)"+ param +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null
==================================================
1、打开PowerDesigner12,在菜单中按照如下方式进行操作
file->Reverse Engineer->DataBase
点击后,弹出 New Physical Data Model 的对话框
2、在General选项卡中
Model name:模板名字,自
网站配置是apache+tomcat,tomcat没有报错,apache报错是:
The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /. Reason: Error reading fr
Free variable A free variable of an expression is a variable that’s used inside the expression but not defined inside the expression. For instance, in the function literal expression (x: Int) => (x
Part Ⅰ:
《阿甘正传》Forrest Gump经典中英文对白
Forrest: Hello! My names Forrest. Forrest Gump. You wanna Chocolate? I could eat about a million and a half othese. My momma always said life was like a box ochocol
Json在数据传输中很好用,原因是JSON 比 XML 更小、更快,更易解析。
在Java程序中,如何使用处理JSON,现在有很多工具可以处理,比较流行常用的是google的gson和alibaba的fastjson,具体使用如下:
1、读取json然后处理
class ReadJSON
{
public static void main(String[] args)