微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – Spring Ehcache MBean Monitoring

我使用的是Spring 4.0.3.RELEASE和EHcache 2.8.1.在JBoss 7.1.1上

通过applicationContext.xml中的以下配置,我的缓存工作正常.

factorybean">
   figLocation" value="/WEB-INF/ehcache.xml"/>

现在我想用MBean添加监视功能.我在applicationContext.xml中更改了配置,如下所示 – 添加了2个新bean“managementService”和“mbeanServer”,没有其他更改.
这是当前配置.

dispose">

        factorybean">
   figLocation" value="/WEB-INF/ehcache.xml"/>
factorybean">
    

使用此配置,我在应用程序服务器启动时收到以下错误.

14:05:32,208 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Context initialization Failed: org.springframework.beans.factory.UnsatisfiedDependencyException: **Error creating bean with name 'managementService'** defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [net.sf.ehcache.CacheManager]: Could not convert constructor argument value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: Failed to convert value of type 'org.springframework.cache.ehcache.EhCacheCacheManager' to required type 'net.sf.ehcache.CacheManager'; nested exception is java.lang.IllegalStateException: **Cannot convert value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]**: no matching editors or conversion strategy found

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'managementService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [net.sf.ehcache.CacheManager]: Could not convert constructor argument value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: Failed to convert value of type 'org.springframework.cache.ehcache.EhCacheCacheManager' to required type 'net.sf.ehcache.CacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: no matching editors or conversion strategy found
最佳答案
您应该将ehcache bean传递给managementService bean的构造函数而不是cacheManager.如果查看cacheManager的定义,ehcache bean将作为cacheManager传递.工厂bean将提供net.sf.ehcache.CacheManager的实例.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐