我正在使用JMX方法可视化在Spring Web项目中使用Ehcache存储的缓存数据。每当我在Jconsole中单击getCache()方法时,都会收到以下错误。有人可以帮我吗?预先感谢
配置文件:
@Configuration
@EnableCaching
public class SpringCachePocConfig implements CachingConfigurer {
net.sf.ehcache.CacheManager newCacheManager;
@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {
//Construct you cache here.
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
config.addCache(<Your cache>);
this.newCacheManager = new net.sf.ehcache.CacheManager(config);
return newCacheManager;
}
@Bean
public ManagementService managementService() {
return new ManagementService(ehCacheManager(), mbeanServer(), true, true, true, true);
}
@Bean
@Override
public CacheManager cacheManager() {
return new EhCacheCacheManager(ehCacheManager());
}
@Bean
public MBeanServer mbeanServer() {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
return mBeanServer;
}
@PostConstruct
public void init() {
ManagementService.registerMBeans(ehCacheManager(), mbeanServer(), true, true, true, true);
}
}
答案 0 :(得分:1)
您必须在jconsole.exe -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;<<ehcache.jar>>
之类的jconsole类路径上添加ehcache jar文件(及其支持的jar文件,如果有的话)。从工具-JConsole
java.rmi.UnmarshalException