gpt4 book ai didi

spring - 同一个 VM 中已存在另一个同名 'cacheManager' 的 CacheManager

转载 作者:行者123 更新时间:2023-12-03 17:39:33 25 4
gpt4 key购买 nike

使用 ehcache 和 Spring 启动 tomcat 时收到此错误。

Another CacheManager with same name '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.
  • Spring 3.1
  • ehcache 2.9.0
  • 没有使用这个的测试上下文。
  • 这是一个 Web JSF 应用程序。

  • 缓存文件
             <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="ehcache.xsd"
    updateCheck="true"
    monitoring="autodetect"
    dynamicConfig="true"
    name="ehcacheManager"
    >
    ....

    </ehcache>

    缓存上下文.xml
            <bean id="cacheManager" 

    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" scope="singleton">
    <property name="shared" value="true"/>
    <property name="configLocation">
    <value>classpath:ehcache.xml</value>
    </property>
    </bean>

    我确实有对 hibernate-ehcache 的旧依赖,不幸的是我无法删除。这可能是问题吗?
      <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>3.5.0-Final</version>
    </dependency>

    有什么建议?
    谢谢!

    最佳答案

    这里讨论了一些解决方案 here

    并且您可能需要提供 ehcache.xml 或设置缓存名称,如您所见 here

    编辑:ApplicationContext 加载两次

    如果您遇到断点,请向上堆栈跟踪,您可能会发现为什么 spring 两次加载上下文。

    关于spring - 同一个 VM 中已存在另一个同名 'cacheManager' 的 CacheManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39578357/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com