当前位置: 首页 > news >正文

常州做网站的 武进wordpress自定义字段位置

常州做网站的 武进,wordpress自定义字段位置,asp网站打不开,完整的网站开发流程如果在网上查找使用Spring 3.1内置缓存的示例#xff0c;那么通常会碰到Spring的SimpleCacheManager #xff0c;Spring的家伙说这对“用于测试或简单的缓存声明很有用”。 实际上#xff0c;我更喜欢将SimpleCacheManager看作是轻量级的#xff0c;而不是简单的。 在您希望… 如果在网上查找使用Spring 3.1内置缓存的示例那么通常会碰到Spring的SimpleCacheManager Spring的家伙说这对“用于测试或简单的缓存声明很有用”。 实际上我更喜欢将SimpleCacheManager看作是轻量级的而不是简单的。 在您希望每个JVM占用少量内存缓存的情况下很有用。 如果Spring的家伙正在经营一家超市那么SimpleCacheManager将属于他们自己品牌的“基本”产品范围。 另一方面如果您需要一个可扩展持久和分布式的重型缓存则Spring还附带内置的ehCache包装器。 好消息是Spring的缓存实现之间的交换很容易。 从理论上讲这完全是配置问题为了证明该理论正确我从Caching和Cacheable博客中获取了示例代码并使用EhCache实现对其进行了运行。 配置步骤与我上一篇博客“ 缓存和配置”中描述的步骤相似您仍然需要指定 cache:annotation-driven / …在您的Spring配置文件中以打开缓存。 您还需要定义一个id为cacheManager的bean只是这一次您引用Spring的EhCacheCacheManager类而不是SimpleCacheManager 。 bean idcacheManagerclassorg.springframework.cache.ehcache.EhCacheCacheManagerp:cacheManager-refehcache/ 上面的示例演示了EhCacheCacheManager配置。 注意它引用了另一个ID为“ ehcache ”的bean。 配置如下 bean idehcache classorg.springframework.cache.ehcache.EhCacheManagerFactoryBeanp:configLocationehcache.xmlp:sharedtrue/ “ ehcache ”具有两个属性 configLocation和shared 。 “ configLocation ”是一个可选属性用于指定ehcache配置文件的位置。 在测试代​​码中我使用了以下示例文件 ?xml version1.0 encodingUTF-8? ehcache xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocationhttp://ehcache.org/ehcache.xsddefaultCache eternaltrue maxElementsInMemory100 overflowToDiskfalse /cache nameemployee maxElementsInMemory10000 eternaltrue overflowToDiskfalse / /ehcache …这将创建两个缓存一个默认缓存和一个名为“员工”的缓存。 如果缺少此文件则EhCacheManagerFactoryBean只需选择一个默认的ehcache配置文件 ehcache-failsafe.xml 该文件位于ehcache的ehcache-core jar文件中。 另一个EhCacheManagerFactoryBean属性是 shared 。 这被认为是可选的因为文档指出它定义了“ EHCache CacheManager是应该共享作为VM级别的单例还是独立的通常在应用程序内部。 默认值为false创建一个独立的实例。” 但是如果将其设置为false则将收到以下异常 org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.cache.interceptor.CacheInterceptor#0: Cannot resolve reference to bean cacheManager while setting bean property cacheManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name cacheManager defined in class path resource [ehcache-example.xml]: Cannot resolve reference to bean ehcache while setting bean property cacheManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ehcache defined in class path resource [ehcache-example.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: InputStreamConfigurationSource [streamjava.io.BufferedInputStream424c414]at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveReference(BeanDefinitionValueResolver.java:328)at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. populateBean(AbstractAutowireCapableBeanFactory.java:1118)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. doCreateBean(AbstractAutowireCapableBeanFactory.java:517)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. createBean(AbstractAutowireCapableBeanFactory.java:456) ... stack trace shortened for clarityat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner. java:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner. run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner. main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name cacheManager defined in class path resource [ehcache-example.xml]: Cannot resolve reference to bean ehcache while setting bean property cacheManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ehcache defined in class path resource [ehcache-example.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: InputStreamConfigurationSource [streamjava.io.BufferedInputStream424c414]at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveReference(BeanDefinitionValueResolver.java:328)at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) ... stack trace shortened for clarityat org.springframework.beans.factory.support.AbstractBeanFactory. getBean(AbstractBeanFactory.java:193)at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveReference(BeanDefinitionValueResolver.java:322)... 38 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ehcache defined in class path resource [ehcache-example.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: InputStreamConfigurationSource [streamjava.io.BufferedInputStream424c414]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. initializeBean(AbstractAutowireCapableBeanFactory.java:1455)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. doCreateBean(AbstractAutowireCapableBeanFactory.java:519)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. createBean(AbstractAutowireCapableBeanFactory.java:456)at org.springframework.beans.factory.support.AbstractBeanFactory$1 .getObject(AbstractBeanFactory.java:294)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry. getSingleton(DefaultSingletonBeanRegistry.java:225)at org.springframework.beans.factory.support.AbstractBeanFactory. doGetBean(AbstractBeanFactory.java:291)at org.springframework.beans.factory.support.AbstractBeanFactory. getBean(AbstractBeanFactory.java:193)at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveReference(BeanDefinitionValueResolver.java:322)... 48 more Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: InputStreamConfigurationSource [streamjava.io.BufferedInputStream424c414]at net.sf.ehcache.CacheManager.assertNoCacheManagerExistsWithSameName(CacheManager. java:521)at net.sf.ehcache.CacheManager.init(CacheManager.java:371)at net.sf.ehcache.CacheManager.(CacheManager.java:339)at org.springframework.cache.ehcache.EhCacheManagerFactoryBean. afterPropertiesSet(EhCacheManagerFactoryBean.java:104)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. initializeBean(AbstractAutowireCapableBeanFactory.java:1452)... 55 more …当您尝试运行一系列单元测试时。 我认为这归结为Spring的ehcache管理器工厂的一个简单错误因为它试图使用new()创建多个缓存实例而不是使用“其中一种CacheManager.create静态工厂方法”作为例外允许其重用相同名称的相同CacheManager。 因此我的第一个JUnit测试工作正常但其他所有测试均失败。 令人反感的代码行是 this.cacheManager (this.shared ? CacheManager.create() : new CacheManager()); 为了完整性下面列出了我的完整XML配置文件 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:phttp://www.springframework.org/schema/pxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:cachehttp://www.springframework.org/schema/cache xmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsdhttp://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd!-- Switch on the Caching --cache:annotation-driven /!-- Do the component scan path --context:component-scan base-packagecaching /bean idcacheManager classorg.springframework.cache.ehcache.EhCacheCacheManager p:cacheManager-refehcache/bean idehcache classorg.springframework.cache.ehcache.EhCacheManagerFactoryBean p:configLocationehcache.xml p:sharedtrue/ /beans 在使用ehcache时要考虑的唯一其他配置详细信息是Maven依赖项。 这些非常简单因为Ehcache的专家们将所有各种ehcache jar组合到一个Maven POM模块中。 可以使用下面的XML将该POM模块添加到项目的POM文件中 dependencygroupIdnet.sf.ehcache/groupIdartifactIdehcache/artifactIdversion2.6.0/versiontypepom/typescopetest/scope/dependency 最后可以从Maven Central和Sourceforge存储库中获得ehcache Jar文件 repositoriesrepositoryidsourceforge/idurlhttp://oss.sonatype.org/content/groups/sourceforge//urlreleasesenabledtrue/enabled/releasessnapshotsenabledtrue/enabled/snapshots/repository/repositories 祝您编程愉快别忘了分享 参考 Spring 3.1来自Captain Debugs Blog博客的JCG合作伙伴 Roger Hughes的缓存和EhCache 。 翻译自: https://www.javacodegeeks.com/2012/10/spring-31-caching-and-ehcache.html
http://www.sadfv.cn/news/107890/

相关文章:

  • 做设计那个素材网站最好中企动力网站建设 医疗
  • 中小企业建站系统wp标题 wordpress
  • 怎样做网站卖东西vps服务器中的网站不显示图片
  • 企业为何要做网站在国外建设网站
  • 网站设置不能通过链接访问做网站怎样才能接单
  • 昆明网站如何制作专业做物业网站的公司
  • 网站建设工作方案铜仁北京网站建设
  • wordpress开启多站点后台没显示潮州哪里有做网站
  • 破解空间网站网络工程规划与设计方案
  • 宁金诚信建设网站旅游网站建设那家好
  • 桂林 网站 制作浙江省住房城乡建设厅网站
  • 学会网站建设的重要性网站建设四川
  • 外贸网站 语言网站的seo优化方案
  • 服务类网站开发大力推进网站集约化建设
  • 做空包网站wordpress替换表情变小
  • 企业网站 域名注册优化seo网站西安
  • 折扣网站搭建有需要做网站推广找我
  • 发布软文的平台有哪些微信搜一搜seo优化
  • 淄博网站制作服务个人网站设计制作步骤
  • 做网站的流程视频教程国家建设人才网站
  • 做音乐网站的目地1688做网站需要多少钱
  • 马鞍山建设网站网站设计网上培训学校
  • 浙江省住房建设厅网站企业网站备案案例
  • 非遗文化网站建设深圳市宝安区投资推广署官网
  • 大淘客平台怎么做分销网站建设网站需要什么资质
  • 网站项目建设规划书案例广州优壹网络科技有限公司
  • 太仓建设银行网站佛山网上推广
  • 网站中怎么做图片的变换湛江人才网招聘官方网
  • 足球网站网站建设优质视频素材网站
  • 在百度搜索到自己的网站企业网站主页设计