SSM报错“No bean named 'cacheManager' is defined”

错误

No bean named 'cacheManager' is defined。

错误代码

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/cache
       http://www.springframework.org/schema/cache/spring-cache.xsd">

    <!-- 使用扫描机制,扫描包 -->
    <context:component-scan base-package="controller"/>
    <context:component-scan base-package="service"/>
    <context:component-scan base-package="dao"/>
    <context:component-scan base-package="pojo"/>

    <mvc:annotation-driven/>

    <!-- 配置视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          id="internalResourceViewResolver">
        <!-- 前缀 -->
        <property name="prefix" value="/html/"/>
        <!-- 后缀 -->
        <property name="suffix" value=".html"/>
    </bean>
</beans>

原因

IDEA会自动补全为cache。

SSM报错“No bean named 'cacheManager' is defined”

解决

将cache改为mvc。

SSM报错“No bean named 'cacheManager' is defined”

正确代码

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/cache/spring-mvc.xsd">

    <!-- 使用扫描机制,扫描包 -->
    <context:component-scan base-package="controller"/>
    <context:component-scan base-package="service"/>
    <context:component-scan base-package="dao"/>
    <context:component-scan base-package="pojo"/>

    <mvc:annotation-driven/>

    <!-- 配置视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          id="internalResourceViewResolver">
        <!-- 前缀 -->
        <property name="prefix" value="/html/"/>
        <!-- 后缀 -->
        <property name="suffix" value=".html"/>
    </bean>
</beans>

 

SSM报错“No bean named 'cacheManager' is defined”SSM报错“No bean named 'cacheManager' is defined” 二木成林 发布了399 篇原创文章 · 获赞 42 · 访问量 9万+ 私信 关注
上一篇:[Vue warn]: Failed to mount component: template or render function not defined.


下一篇:学习笔记-移植U-boot 2012 04 01 到JZ2440(2.1)——启动过程概述