緩存ehcache啟動失敗missing element type


啟動失敗了,報了如下錯誤:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheCacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/EhCacheCacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.sf.ehcache.CacheManager]: Factory method 'ehCacheCacheManager' threw exception; nested exception is net.sf.ehcache.CacheException: java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type

以前一直在用,沒有問題,新項目報錯。

新項目唯一不同的是嘗試了easyexcel,我好像知道些什么了。

查看easyexcel的pom.xml,找到了這個。

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

基本上定位問題所在了,org.ehcache和net.sf.ehcache有沖突,那么既然easyexcel已經引用了,我們就去掉net.sf.ehcache。

 

然后依然報錯,有了新的提示,告訴我們無法連接redis,懂了。

那么我們嘗試一下用net.sf.ehcache,排除org.ehcache。

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>easyexcel</artifactId>
    <version>2.2.3</version>
    <exclusions>
        <exclusion>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
        </exclusion>
    </exclusions>
</dependency>

啟動成功了。

 

吐槽:阿里的開源框架原來代碼寫得這么坑。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM