继续上一篇https://blog.youkuaiyun.com/sky_jiangcheng/article/details/86513900,搭建ssm项目过程中,配置缓存管理(cacheManager)之后,
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml" />
<property name="shared" value="true"/>
</bean>
<!-- 开启spring缓存 -->
<cache:annotation-driven cache-manager="cacheManager" />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehCacheManager"></property>
</bean>
报找不到 org.springframework.cache.ehcache.EhCacheManagerFactoryBean,然后我就发现 cache 目录在 spring-context 的包下,该包下没有ehcache目录,如图显示找不到对应的类

cache进入了context包 如图

判断是缺少了包,经过搜索找到了原来是缺少 spring-context-support 包
解决方案:
1,添加依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
更新maven仓库 顺利运行
本文详细解析了在SSM项目中配置Spring缓存管理(cacheManager)时遇到的问题及解决办法,特别是关于org.springframework.cache.ehcache.EhCacheManagerFactoryBean类未找到的错误,介绍了如何通过添加spring-context-support依赖来解决这一问题。
1万+

被折叠的 条评论
为什么被折叠?



