项目原来在springboot基础上引用了shiro中的ehcache,后来集成了springcloud-eureka-server会报以下错误:
io.micrometer.core.instrument.binder.cache.EhCache2Metrics.<init>(EhCache2Metrics.java:36)
The following method did not exist:
net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;
The method's class, net.sf.ehcache.Ehcache, is available from the following locations:
jar:file:/D:/maven/my_local_repository/net/sf/ehcache/ehcache-core/2.6.11/ehcache-core-2.6.11.jar!/net/sf/ehcache/Ehcache.class
It was loaded from the following location:
file:/D:/maven/my_local_repository/net/sf/ehcache/ehcache-core/2.6.11/ehcache-core-2.6.11.jar
查看EhCache2Metrics发现是初始化时候,StatisticsGateway引用不正确。
这个原因是由于io.micrometer.core中的引用于ehcache冲突,于是在引用eureka-server时将这个包去除掉。pom文件配置如下:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<!-- 与shiro中的ehcache冲突-->
<exclusions>
<exclusion>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</exclusion>
</exclusions>
</dependency>