ehcache-root与ehcache-root全部版本对应关系
时间: 2023-12-27 21:04:44 浏览: 46
ehcache-root 是 Ehcache 缓存框架的版本号,而 Ehcache 又有多个不同的版本,每个版本的 ehcache-root 号码也不同。以下是一些常见的 Ehcache 版本与对应的 ehcache-root:
- Ehcache 2.10.x:ehcache-root=2.10
- Ehcache 2.9.x:ehcache-root=2.9
- Ehcache 2.8.x:ehcache-root=2.8
- Ehcache 2.7.x:ehcache-root=2.7
- Ehcache 3.0.x:ehcache-root=3.0
- Ehcache 3.1.x:ehcache-root=3.1
- Ehcache 3.2.x:ehcache-root=3.2
请注意,这些版本号只是示例,如果您在使用 Ehcache 时需要获取确切的版本号,请查阅相应的文档或者 Maven 依赖信息。
相关问题
ehcache-root与ehcache-root版本对于关系
`ehcache-root` 是 Ehcache 的 Maven 父项目,它定义了 Ehcache 的版本、依赖项和插件等信息。而 `ehcache-root` 的版本与 Ehcache 版本是对应的,比如 `ehcache-root` 版本为 `3.8.1` 则对应的 Ehcache 版本也为 `3.8.1`。
因此,在使用 Ehcache 时,我们需要引用正确版本的 `ehcache-root`,以确保 Ehcache 的依赖项和插件等与版本相匹配,避免出现不兼容的情况。
Spring Boot 怎么 配置ehcache数据永不丢失
要在 Spring Boot 中配置 Ehcache 数据永不丢失,需要进行以下步骤:
1. 添加 Ehcache 依赖
在 pom.xml 文件中添加 Ehcache 依赖:
```
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.11</version>
</dependency>
```
2. 配置 Ehcache
在 application.properties 文件中配置 Ehcache:
```
spring.cache.type=ehcache
spring.cache.ehcache.config=classpath:ehcache.xml
```
其中,ehcache.xml 文件的内容如下:
```
<ehcache>
<diskStore path="java.io.tmpdir/ehcache"/>
<defaultCache
maxElementsInMemory="10000"
eternal="true"
overflowToDisk="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
```
其中,eternal 属性设置为 true,即数据永不过期;diskPersistent 属性设置为 true,即数据持久化到磁盘。
3. 配置数据源
在 application.properties 文件中配置数据源:
```
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
```
4. 使用 Ehcache
在代码中使用 Ehcache:
```
@Autowired
private CacheManager cacheManager;
public void put(String key, Object value) {
Cache cache = cacheManager.getCache("myCache");
cache.put(key, value);
}
public Object get(String key) {
Cache cache = cacheManager.getCache("myCache");
return cache.get(key, Object.class);
}
```
其中,"myCache" 是 Ehcache 中定义的缓存名称。可以通过如下方式创建缓存:
```
@Bean
public EhCacheCacheManager cacheManager() {
return new EhCacheCacheManager(ehCacheFactoryBean().getObject());
}
@Bean
public EhCacheManagerFactoryBean ehCacheFactoryBean() {
EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
ehCacheManagerFactoryBean.setShared(true);
return ehCacheManagerFactoryBean;
}
@Bean
public CacheManager cacheManager() {
return new ConcurrentMapCacheManager();
}
```
这样就配置好了 Ehcache,数据可以永不丢失。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)