springboot3整合ehcache3

在springboot3.x版本中,缓存管理的相关标签有所改动,官方文档中对于支持缓存提供者的部分示例如下,不再有一个ehcache标签指定ehcache,而是统一为jcache(java缓存通用标准)即可识别。

# Only necessary if more than one provider is present
spring:
  cache:
    jcache:
      provider: "com.example.MyCachingProvider"
      config: "classpath:example.xml"

spring官方说明如下

JCache is bootstrapped through the presence of a javax.cache.spi.CachingProvider on the classpath (that is, a JSR-107 compliant caching library exists on the classpath), and the JCacheCacheManager is provided by the spring-boot-starter-cache “Starter”. Various compliant libraries are available, and Spring Boot provides dependency management for Ehcache 3, Hazelcast, and Infinispan. Any other compliant library can be added as well.

It might happen that more than one provider is present, in which case the provider must be explicitly specified. Even if the JSR-107 standard does not enforce a standardized way to define the location of the configuration file, Spring Boot does its best to accommodate setting a cache with implementation details, as shown in the following example:

翻译

JCache是通过classpath上存在javax.cache.spi.CachingProvider来引导的(也就是说,classpath上存在一个符合JSR-107标准的缓存库),JCacheCacheManager由spring-boot-starter-cache "启动器 "提供。有各种兼容的库,Spring Boot为Ehcache 3、Hazelcast和Infinispan提供依赖性管理。也可以添加任何其他兼容的库。

可能会出现不止一个提供者的情况,在这种情况下,必须明确指定提供者。即使JSR-107标准没有强制要求以标准化的方式定义配置文件的位置,Spring Boot也会尽力适应设置缓存的实现细节,如下面的例子所示:

猜你喜欢

转载自blog.csdn.net/m0_54250110/article/details/130144884