【问题标题】:java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element typejava.lang.annotation.IncompleteAnnotationException:org.terracotta.statistics.Statistic 缺少元素类型
【发布时间】:2018-04-06 15:22:02
【问题描述】:

我的项目有 hibernate 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 需要启动 2x。如何解决这个问题

【问题讨论】:

  • Spring Boot 根本不需要 EhCache,更不用说它的特定版本了。您的应用程序的其他依赖项之一可能是,但您尚未提供有关它们的任何信息。
  • 同样的问题,我用的是hibernate eh-cache

标签: hibernate spring-boot ehcache-3 ehcache-2


【解决方案1】:

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

    <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>

【讨论】:

    【解决方案2】:

    通过使用修复了问题,

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

    【讨论】:

    • 你能解释一下吗?
    猜你喜欢
    • 1970-01-01
    • 2020-02-07
    • 2020-12-20
    • 1970-01-01
    • 2014-06-17
    • 2012-04-24
    • 2013-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多