Spring Ehcache MBean监视

山姆

我正在使用Spring 4.0.3.RELEASE和EHcache 2.8.1。在JBoss 7.1.1上

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

<cache:annotation-driven/>

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
   <property name="cacheManager" ref="ehcache"/>
</bean>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
   <property name="configLocation" value="/WEB-INF/ehcache.xml"/>
</bean>

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

<cache:annotation-driven/>

<bean id="managementService"
        class="net.sf.ehcache.management.ManagementService"
        init-method="init"
        destroy-method="dispose">

        <constructor-arg ref="cacheManager"/>
        <constructor-arg ref="mbeanServer"/>
        <constructor-arg index="2" value="true"/>
        <constructor-arg index="3" value="true"/>
        <constructor-arg index="4" value="true"/>
        <constructor-arg index="5" value="true"/>
 </bean>

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
   <property name="cacheManager" ref="ehcache"/>
</bean>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
   <property name="configLocation" value="/WEB-INF/ehcache.xml"/>
</bean>    

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
    <property name="locateExistingServerIfPossible" value="true"/>
</bean>

使用此配置,在应用程序服务器启动时出现以下错误。

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
普里耶什

您应该将ehcachebean传递managementServicenotbean的构造函数cacheManager如果您看一下bean的定义,cacheManager则将ehcache其传递为cacheManager工厂bean将提供的实例net.sf.ehcache.CacheManager

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

通过JMX监视Ehcache

来自分类Dev

Spring Boot EHcache cacheResolver

来自分类Dev

Spring框架中的ehcache配置

来自分类Dev

通过Spring / MyBatis了解EhCache

来自分类Dev

使用Spring的cut ehcache逐出策略

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

Spring Boot,使用EhCache进行缓存

来自分类Dev

使用Spring以编程方式驱逐Ehcache元素

来自分类Dev

Ehcache Java Spring MVC和分页@Cacheable

来自分类Dev

使用Spring的cut ehcache逐出策略

来自分类Dev

Spring ehcache查找了错误的CacheManager

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

无法启动EHCache和Spring Boot

来自分类Dev

Spring Boot不会初始化Ehcache

来自分类Dev

将ehcache:proxy迁移到spring 4

来自分类Dev

使用 ehcache 的 Spring 实现配置 JMX?

来自分类Dev

多Maven项目中的Spring Boot ehcache

来自分类Dev

无法通过Spring注册MBean

来自分类Dev

监视Tomcat StandardThreadExecutor的队列大小(MBean)

来自分类Dev

监视Tomcat StandardThreadExecutor的队列大小(MBean)

来自分类Dev

在没有XML的Spring 4中使用EhCache

来自分类Dev

ehcache与Spring。找不到Google Code XSD文件

来自分类Dev

带有Ehcache @CacheEvict的Spring Cache不起作用

来自分类Dev

Spring + Hibernate + Ehcache使query_cache永不过期

来自分类Dev

由于ehcache无法编译spring-security-core

来自分类Dev

没有XML的EhCache3 + Spring Boot 2

来自分类Dev

由于ehcache无法编译spring-security-core

来自分类Dev

使用+ Spring + Struts应用程序的ehcache并发修改异常

来自分类Dev

SelfPopulatingCache 现有缓存问题(Spring 4,EhCache 2.10.3)