【问题标题】:ehcache warning message " No configuration found"ehcache 警告消息“未找到配置”
【发布时间】:2009-11-26 23:10:44
【问题描述】:

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

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 Code

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

【问题讨论】:

    标签: hibernate spring ehcache


    【解决方案1】:

    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年后,希望我的回答能帮助到别人。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

        • 这并没有回答原来的问题。 OP 询问故障安全 xml 的影响
        猜你喜欢
        • 2020-12-02
        • 1970-01-01
        • 2018-03-31
        • 1970-01-01
        • 2020-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多