14

应用程序启动时,我收到以下警告。

2009-05-13 09:19:41,171 WARN  net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath:jar:file:/app/java/lib/ehcache-1.1.jar!/ehcache-failsafe.xml  

我在以下 url 中找到了 encache 代码 .. ConfigurationFactory 代码

应用程序正在尝试加载 ehcache.xml 但找不到该文件,因此它会加载 ehcache-failsafe.xml。我想知道这会对应用程序造成任何问题吗?加载 ehcache-failsafe.xml 有什么影响?

4

3 回答 3

33

ehcache.xml应该在你的classpath,特别是在WEB-INF/classes/. 然后,您可以根据您的环境在其中指定您的需求。

这是一个例子:

<?xml version="1.0" encoding="UTF-8"?>

<ehcache>
    <diskStore path="java.io.tmpdir"/>

    <cache name="org.hibernate.cache.UpdateTimestampsCache"
           maxElementsInMemory="50000"
           eternal="true"
           overflowToDisk="true"/>

    <cache name="org.hibernate.cache.StandardQueryCache"
           maxElementsInMemory="50000"
           eternal="false"
           timeToIdleSeconds="120"
           timeToLiveSeconds="120"
           overflowToDisk="true"
           diskPersistent="false"
               diskExpiryThreadIntervalSeconds="120"
           memoryStoreEvictionPolicy="LRU"
            />

    <defaultCache
            maxElementsInMemory="50000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />

</ehcache>

3年后,希望我的回答可以帮助别人。

于 2012-04-02T15:03:05.983 回答
11

加载ehcache-failsafe.xml本身不会导致问题;但是它很可能不是您的应用程序的最佳选择。

EhCache 开发人员无法知道您打算缓存什么;因此ehcache-failsafe.xml包含在分发尝试中以提供一些“最低公分母”设置,这些设置在大多数情况下或多或少都可以正常工作。您会收到一条警告,提醒您指定更适合您的特定需求的配置。

于 2009-11-26T23:25:17.527 回答
0

如果您使用 Ehcache 作为休眠更改的二级缓存提供程序: hibernate.cache.provider_configuration_file_resource_path 和 net.sf.ehcache.configurationResourceName Ehcache 将能够找到您的配置。

于 2017-03-18T20:31:09.490 回答