3

我的项目有休眠 l2 缓存并使用 ehcache 通过此配置进行管理

hibernate.cache.region.factory_class:org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory

迁移到 Spring boot 2 后,我得到了这个异常

Caused by: java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type
    at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
    at com.sun.proxy.$Proxy151.type(Unknown Source)
    at org.terracotta.statistics.StatisticsManager.parseStatisticAnnotations(StatisticsManager.java:114)
    at org.terracotta.context.ContextManager.contextCreated(ContextManager.java:183)
    at org.terracotta.context.ContextManager.getOrCreateTreeNode(ContextManager.java:136)
    at org.terracotta.context.ContextManager.associate(ContextManager.java:114)
    at org.terracotta.context.ContextManager.access$000(ContextManager.java:38)
    at org.terracotta.context.ContextManager$1.withChild(ContextManager.java:57)
    at org.terracotta.statistics.StatisticsManager.createOperationStatistic(StatisticsManager.java:55)
    at org.terracotta.statistics.StatisticsManager.createOperationStatistic(StatisticsManager.java:50)
    at net.sf.ehcache.statistics.StatisticBuilder$OperationStatisticBuilder.build(StatisticBuilder.java:79)
    at net.sf.ehcache.Cache.<init>(Cache.java:268)
    at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:305)
    at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:223)
    at net.sf.ehcache.CacheManager.configure(CacheManager.java:783)
    at net.sf.ehcache.CacheManager.doInit(CacheManager.java:470)
    at net.sf.ehcache.CacheManager.init(CacheManager.java:394)
    ... 42 common frames omitted

问了一些问题后,我发现 ehcache 2x 和 3 x 在我的项目中都有,异常原因是这样,但是当排除 2x 时,请参阅 spring 需要启动 2 x。如何解决这个问题

4

2 回答 2

3

通过替换解决了这个问题:

    <dependency>
        <groupId>org.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>

具有以下内容:

   <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>

从 Spring Boot 2.0.2 开始

消除:

spring.jpa.properties.hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory

消除:

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>
于 2018-05-04T23:27:36.717 回答
0

通过使用修复了问题,

<dependency>
    <groupId>org.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>3.0.0</version>
</dependency>
于 2018-10-09T16:49:23.693 回答