創建空的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