【发布时间】:2019-03-19 08:54:31
【问题描述】:
我正在尝试将当前使用 Ehcache 2 的 Spring Boot 项目迁移到最新的 Ehcache 3.7。
一切似乎都很好,除了缺少 Spring Boot Admin 缓存统计信息。
这里是之前的 Ehcache 2 配置:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="false"
monitoring="on"
dynamicConfig="true"
statistics="true">
<cache name="asset"
maxEntriesLocalHeap="5"
timeToIdleSeconds="600"
timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU"/>
</ehcache>
以及新的 Ehcache 3 配置:
<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.6.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.6.xsd">
<service>
<jsr107:defaults enable-management="true" enable-statistics="true"/>
</service>
<cache alias="asset">
<resources>
<heap unit="entries">5</heap>
</resources>
<expiry>
<ttl unit="hours">1</ttl>
</expiry>
<jsr107:mbeans enable-management="true" enable-statistics="true"/>
</cache>
</config>
POM 依赖(仅与缓存管理相关的):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.7.0</version>
</dependency>
弹簧配置:
spring:
cache:
ehcache:
config: classpath:ehcache.xml
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
hbm2ddl:
auto: none
cache:
use_second_level_cache: true
region:
factory_class: jcache
javax:
cache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
missing_cache_strategy: fail
我曾经用 Ehcache 2 获得这种统计数据:
但使用 Ehcache 3,SBA 洞察/详细信息页面和数据/缓存一页上都不会显示任何统计信息。
在 Ehcache 2 中,它非常适合即插即用,但在 Ehcache 3 中似乎并非如此。
有人有提示吗?
谢谢!
【问题讨论】:
标签: spring-boot ehcache spring-boot-actuator spring-boot-admin ehcache-3