创建空的Grails项目使用Grails集成兵马俑
grails create-app foo
修改BuildConfig.groovy
,取消注释
inherits("global") {
// uncomment to disable ehcache
excludes 'ehcache'
}
所以现在ehcache
被排除在外。
复制这5个罐子从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
在grails-app/conf/
目录中创建ehcache.xml
:
<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 run-app
运行项目,并得到此异常:
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager':
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cache.CacheException:
net.sf.ehcache.CacheException: Could not create ClusteredInstanceFactory due to missing class. Please verify that terracotta-toolkit is in your classpath.
您使用的是哪个版本的grails? – allthenutsandbolts
2.1.1其实问题已经解决了。 – Archer