CacheManager No Bean Found - Not Trying to setup any Cache

后端 未结 4 516
故里飘歌
故里飘歌 2021-02-05 19:02

I\'m getting a no CacheManager bean found... But i have not tried to do anything with CacheManager!

Here\'s my error!

org.springframework.beans.factory.B         


        
相关标签:
4条回答
  • 2021-02-05 19:45

    I added exactly the line for mvc:

    xmlns: MVC = "http://www.springframework.org/schema/mvc"

    Plus: mvc: annotation-driven

    And it works perfectly!

    0 讨论(0)
  • 2021-02-05 19:47

    Using IntelliJ IDEA v15 I let it create the Spring Context file for my rest servlet then I added the context: and mvc: lines:

    <?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="com.iqss" />
        <mvc:annotation-driven />
    </beans>
    

    I had exactly the same error as the OP. I had no need for Spring caching, but it had added the name space, so to fix it I just removed the namespace (and I needed to add the mvc namespace too), as follows:

    <?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/mvc/spring-mvc.xsd">
    
        <context:component-scan base-package="com.iqss" />
        <mvc:annotation-driven />
    </beans>
    

    I hope this helps.

    0 讨论(0)
  • 2021-02-05 19:48

    In your context files, if you use <tx:, IntelliJ automatically imports the ****/cache namespace instead of the ****/tx namespace! So when I had my <tx: tag for transactional manager, it was thinking it was cacheManager.

    0 讨论(0)
  • 2021-02-05 19:52

    I had the same problem, As tehras said, if you use Intellij IDEA and use <tx:, then it will become ****/cache namespace, so change it to tx namespace to fix it.

    xmlns:tx="http://www.springframework.org/schema/tx"

    and in xsi:schemaLocation, find **/schema/cache and replace it with

    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd

    Restart your project and it will be ok.

    0 讨论(0)
提交回复
热议问题