如何禁用Ehcache更新检查器?

32

12:18:55,541 信息 [UpdateChecker] 发现新版本更新: 2.0.0 [http://ehcache.org/news.html]

如何禁止 ehcache 检查新版本更新,因为这会在加载 j2ee 应用程序和初始化 ehcache 时发生。


10
这个功能彻底失败了。我不明白他们为什么要这样做。想象一下,如果一个应用的所有 20 个依赖都这样做会发生什么! - cherouvim
@cherouvim:完全同意。谷歌搜索显示一个Jira问题,该问题在5年前被关闭,原因是“不会修复”。这是一种令人难以置信的侵入性行为,尤其是对于开源软件来说。 - Amos M. Carpenter
2个回答

38

一种方法是在classpath上放置一个带有根标签中属性updateCheck="false"ehcache.xml文件。

例如:

<ehcache updateCheck="false">
  <defaultCache
    maxElementsInMemory="0"
    eternal="false"
    timeToIdleSeconds="0"
    timeToLiveSeconds="0"
    overflowToDisk="false"
    diskPersistent="false"/>
</ehcache>

另一种方式是设置环境变量:

System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");

非常感谢,这正是我所需要的。修改 ehcache.xml 文件有所帮助,并且它已经存在于类路径中。 - Joe
2
实际上这部分是正确的,系统属性设置会起作用,但仅仅将ehcache xml文件放在类路径的根目录下是不行的。您还必须像@Anthony Dahanne所描述的那样,在外部ehcache元素中添加updateCheck="false",并在文档中进行说明:http://ehcache.org/documentation/user-guide/configuration。 - TechTrip
当前配置文档位于http://www.ehcache.org/documentation/2.8/configuration/configuration.html#update-checker。 - Gregor

18

简单来说,在您的ehcache.xml配置文件中,确保禁用updateCheck:

<ehcache updateCheck="false">

<defaultCache
        maxElementsInMemory="0"
        eternal="false"
        timeToIdleSeconds="0"
        timeToLiveSeconds="0"
        overflowToDisk="false"
        diskPersistent="false"
        />
</ehcache>

文件必须放在类路径的根目录下。 - Tires

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接