【问题标题】:Grails DSL configuration being ignoredGrails DSL 配置被忽略
【发布时间】:2014-03-05 15:00:45
【问题描述】:

使用 Grails 2.2.3 并尝试通过 DSL 配置缓存,如 here 和 here 所述。

说明指出可以在 Config.groovy 或 CacheConfig.groovy 文件中进行配置。 这必须在 Config.groovy 的 grails.cache.config 键下或在 CacheConfig.groovy 的键 config 下。

我不想缓存 gorm 操作。休眠完全关闭。需要缓存一些 REST 结果的方法,结果证明这很昂贵,并且可以使用缓存...

我尝试了这两个选项,这个警告表明配置没有被读取:

WARN : net.sf.ehcache.config.ConfigurationFactory: No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/home/myhome/.grails/ivy-cache/net.sf.ehcache/ehcache-core/jars/ehcache-core-2.4.6.jar!/ehcache-failsafe.xml

我现在正在 CacheConfig.groovy 中使用此配置进行测试

config = {
    cache {
        name 'someName'
        //Overwrite these, inherit rest
        timeToIdleSeconds 86400 //I like 24hours
        timeToLiveSeconds 86400
    }
    defaultCache {
        //Just inherit from defaults
    }
    defaults {
        timeToIdleSeconds 120
        timeToLiveSeconds 120
        eternal false
        overflowToDisk false
        maxElementsInMemory 10000
        maxElementsOnDisk 10000000
        memoryStoreEvictionPolicy="LRU"
    }
}

这可能是 grails-cache-plugin 错误还是我遗漏了什么?

【问题讨论】:

    标签: grails ehcache


    【解决方案1】:

    该警告是针对 Hibernate 二级缓存中使用的 Ehcache。这是说类路径中没有 ehcache.xml (或在其他地方显式配置),因此它回退到 jar 文件中的默认 xml 文件。这与用于 cache-ehcache 插件的 Ehcache 配置是分开的。

    【讨论】:

    • 我根本没有使用 Hibernate。有什么方法可以抑制警告?
    • 当然,如果您在 src/java 中有一个 ehcache.xml 文件,它将被复制到类路径并使用,而不是 jar 中的默认值。从 jar 中提取 ehcache-failsafe.xml,或使用此(即删除了 cmets 的文件)pastie.org/8882778
    猜你喜欢
    • 2013-03-07
    • 2013-09-12
    • 2016-09-13
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多