Grails 陶土与圣杯的结合
创建了空的grails项目Grails 陶土与圣杯的结合,grails,terracotta,Grails,Terracotta,创建了空的grails项目 grails创建应用程序foo 已修改BuildConfig.groovy,未注释 inherits("global") { // uncomment to disable ehcache
grails创建应用程序foo
已修改BuildConfig.groovy
,未注释
inherits("global") {
// uncomment to disable ehcache
excludes 'ehcache'
}
因此,现在排除了ehcache
将这5个JAR从terracotta
安装复制到foo/lib
目录:
ehcache-core-ee-2.6.2.jar
ehcache-terracotta-ee-2.6.2.jar
slf4j-api-1.6.1.jar
slf4j-jdk14-1.6.1.jar
terracotta-toolkit-1.6-runtime-ee-5.2.0.jar
<ehcache>
<terracottaConfig url="vm4:9510"/>
<defaultCache
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="20"
timeToLiveSeconds="20"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU">
<terracotta clustered="true" valueMode="serialization"/>
</defaultCache>
</ehcache>
在grails app/conf/
目录中创建ehcache.xml
:
ehcache-core-ee-2.6.2.jar
ehcache-terracotta-ee-2.6.2.jar
slf4j-api-1.6.1.jar
slf4j-jdk14-1.6.1.jar
terracotta-toolkit-1.6-runtime-ee-5.2.0.jar
<ehcache>
<terracottaConfig url="vm4:9510"/>
<defaultCache
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="20"
timeToLiveSeconds="20"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU">
<terracotta clustered="true" valueMode="serialization"/>
</defaultCache>
</ehcache>
从
foo/lib
目录中删除所有JAR,并在BuildConfig.groovy中插入一些依赖项:
repositories {
.....
mavenRepo "http://www.terracotta.org/download/reflector/releases"
}
dependencies {
runtime 'net.sf.ehcache:ehcache-core:2.6.2'
runtime 'net.sf.ehcache:ehcache-terracotta:2.6.2'
runtime 'org.terracotta:terracotta-toolkit-1.6-runtime:5.2.0'
}
这将允许从repo和类路径设置中自动下载其他必要的jar
而且,如果您像我一样设置开源terracotta服务器,企业版foo/lib/ehcache-terracotta-ee-2.6.2.jar将导致错误:
错误-企业客户端无法连接到开源服务器,
连接被拒绝
关键部分:
使用grails-noreloading Run app
而不是grails Run app
运行应用程序,以绕过重新加载代理。那么分布式缓存应用程序应该可以工作了
p、 将应用程序部署到生产环境中不需要额外的工作。您使用的是什么版本的grails?2.1.1实际上问题已经解决了。事实上,noreloading做到了这一点。我在lib中保存了jar(没有运行时maven deps),它可以工作。谢谢,伙计,你们知道为什么会这样吗?但是,我希望在开发环境中启用分布式缓存,在开发环境中我还希望自动重新加载。错误消息(jar在类路径中丢失)让我希望以不同的方式解决这个问题!也许你可以试着为这个养一只吉拉?