java - 在重复的 EHCache 上升级 Shiro 到 1.6.0 失败
问题描述
我尝试将 Spring Web 应用程序中的 Shiro 从 1.2.3 升级到 1.6.0。我刚刚修改了gradle中的版本并重新编译了war。但它没有开始:
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: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
at net.sf.ehcache.CacheManager.assertNoCacheManagerExistsWithSameName(CacheManager.java:529)
我不在 Shiro 配置中使用 EHCache:
<import resource="file:${CONFIG_PATH}/ldap-realm.xml"/>
<!-- SHIRO Access control -->
<bean id="securityManager" class="com.cgi.apps.centaur.engine.access.realm.IPOverridingSecurityManager">
<property name="realms" ref="shiroRealms"/>
<property name="cacheManager" ref="memoryConstrainedCacheManager"/>
<property name="sessionManager" ref="sessionManager"/>
</bean>
<bean id="sessionManager" class="com.cgi.apps.centaur.engine.access.realm.IPOverridingSessionManager">
</bean>
<bean id="memoryConstrainedCacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"/>
问题出在哪里?
解决方案
我必须明确选择 gradle 中的包。Shiro 所有导入的 ehcache 模块都有自己的捆绑包ehcache.xml
,这与我的配置冲突。
compile("org.apache.shiro:shiro-core:${versionShiro}") {
exclude group: 'org.sonatype.sisu.inject', module: 'cglib'
}
compile "org.apache.shiro:shiro-web:${versionShiro}", "org.apache.shiro:shiro-spring:${versionShiro}"
推荐阅读
- c++ - 如何防止另一个线程修改状态标志?
- node.js - 回复错误:ERR 未知命令“evalsha”(Node.js,公牛)
- python - 如何在远程主机上运行本地 python 脚本并使用子进程与其通信?
- scala - Scala 中的 def f=x:Int->List(x-1,x,x+1) 有什么问题?
- delphi - 如何在 Indy 10 中复制 cookie
- css - 如何在 CSS 中用 2 种颜色绘制文本?
- php - Wordpress 自定义帖子不会显示在存档-{postname}.php 下
- html - 通过 WebView 中的外部网页加载本地文件
- intellij-idea - 结构搜索并用新变量替换
- asp.net - 如何在 gridview 中添加按钮以链接到网页?