SpringMVC + Mybatis + Shiro + ehcache时缓存管理器报错。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘shiroFilter‘ defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean ‘securityManager‘ while setting bean property ‘securityManager‘;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘securityManager‘ defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean ‘userRealm‘ while setting bean property
‘realm‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userRealm‘ defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean ‘credentialsMatcher‘ while setting
bean property ‘credentialsMatcher‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘credentialsMatcher‘ defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean
‘shiroCacheManager‘ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘shiroCacheManager‘ defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve
reference to bean ‘ehCacheManager‘ while setting bean property ‘cacheManager‘; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘ehCacheManager‘ defined in class path resource [spring/spring-shiro-web.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:

最后红色是关键,说要确保缓存管理器只能有一个!

在shiro1.3以后,要确保缓存管理器是单例的。

所以需要这样配

	<!-- MyBatis使用ehcache缓存 start -->
	<bean id="ehCacheManager"
		class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
		<property name="configLocation" value="classpath:ehcache/shiroEhcache.xml" />
                <property name="shared" value="true"></property> <!-- 这里是关键!!!没有必错  -->
	</bean>
	<!-- end MyBatis使用ehcache缓存 -->
	<!-- 缓存管理器 使用Ehcache实现 -->
	<bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
		<property name="cacheManager" ref="ehCacheManager" />
	</bean>

完整配置文档地址

http://download.csdn.net/detail/tragedyxd/9026633

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-06 10:04:04

SpringMVC + Mybatis + Shiro + ehcache时缓存管理器报错。的相关文章

springmvc + mybatis + shiro + ehcache 源码

A 代码生成器(开发利器);  B 阿里数据库连接池druid; C 安全权限框架shiro ; D ehcache 自定义二级缓存  系统为主流的 springmvc+mybaits 3.2 版本 ,有maven版本和非maven版本,赠送同UI hibernate版本(支持sqlsever mysql oracle)  jdk 1.6 1.7 1.8  tomcat 6 7 8 (响应式 手机 PC 平板 最下面手机截图)1. 有 oracle .msyql.spring3.0.spring

ie11的DOM管理器报错

IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005------------------Diagnostic:Exception in window.onload: Error: An error has ocurredJSPlugin.3005Stack Trace:Error: An error has ocurredJSPlugin.3005 at

SpringMVC+mybatis+maven+Ehcache缓存实现

所谓缓存,就是将程序或系统经常要调用的对象存在内存中,以便其使用时可以快速调用,不必再去创建新的重复的实例.这样做可以减少系统开销,提高系统效率. 缓存主要可分为二大类: 一.通过文件缓存,顾名思义文件缓存是指把数据存储在磁盘上,不管你是以XML格式,序列化文件DAT格式还是其它文件格式: 二.内存缓存,也就是实现一个类中静态Map,对这个Map进行常规的增删查. 一.EhCache缓存系统简介 EhCache 是一个纯 Java 的进程内缓存框架,具有快速.精干等特点,是 Hibernate

SpringMVC + Mybatis + Shiro 权限整合【转】

<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"/> , 否则controller无法使用注解. 这个方法可能避免使用sessionValidationScheduler, 就是避免使用, 就能使用高版本的quartz了. 配置会话监听: Java代码   package com.pandy.core.security.session;

shiro与Web项目整合-Spring+SpringMVC+Mybatis+Shiro(八)

Jar包 Web.xml中配置shiro的filter <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://ja

SpringMVC Mybatis Shiro RestTemplate的实现客户端无状态验证及访问控制【转】

A.首先需要搭建SpringMVC+Shiro环境 a1.pom.xml配置 spring: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId>     <version>4.1.0.RELEASE</version> </dependency> <dependency>

springmvc,mybatis,shiro综合配置示例

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 htt

springmvc,mybatis,shiro综合配置示例【转】

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 htt

javaEE 后台框架 SpringMVC Mybatis Shiro Bootstrap HTML

升级报捷:通过服务于服务之间调用,生成二维码,可直接用户手机app(详细查看截图) 框架集成lucene搜索引擎,使您的信息在毫秒内抓取(详细查看截图) 1.  创建.初始化索引.统一搜索入口.搜索结果展现--内容.标题高亮.关键词搜索 2.  高级搜索:高级搜索增加多入口查询(精确查询.模糊查询.前缀查询等),每页显示条数自定义.索引结果数据设置.选择索引文档类型等 3. 通过A系统调用B系统的Rest服务,生成相关的二维码,可以直接用户手机app ----------------------