spring ehcache 警告消息“未找到配置”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1806068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 03:57:11  来源:igfitidea点击:

ehcache warning message " No configuration found"

hibernatespringehcache

提问by nayakam

I have got following warning when the application start up.

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

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  

I found encache code in following url .. ConfigurationFactory Code

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

Application is trying to load ehcache.xml but could not find the file so then it loads ehcache-failsafe.xml.I would like to know does this cause any problem to application ? what is impact loading ehcache-failsafe.xml ?

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

采纳答案by ChssPly76

Loading ehcache-failsafe.xmldoesn't cause a problemper se; however it most likely isn't optimal for your application.

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

There's no way for EhCache developers to know what you intend to cache; thus ehcache-failsafe.xmlincluded in distribution attempts to provide some "lowest common denominator" settings that would work more or less OK in most cases. You get a warning as a reminder to specify configuration that would be more appropriate for your specific needs.

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

回答by Oueslati Bechir

ehcache.xmlshould be introduced in your classpathand specifically in WEB-INF/classes/. Then, you can specify your needs in it according to your environment.

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

This is an example:

这是一个例子:

<?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>

After 3 years, hope that my response can help others.

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

回答by Meriam

If you re using Ehcache as a second level cache provider for hibernate change : hibernate.cache.provider_configuration_file_resource_path with net.sf.ehcache.configurationResourceName Ehcache will be able to find your configuration then.

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