使用Idea構建springmvc框架,出現no bean named ‘cacheManager’ is defined 錯誤。
轉自:https://blog.csdn.net/qq_23184291/article/details/78086398
配置springmvc-servlet.xml檔案,配置好包掃描,mvc註解,及檢視解釋配置
由於IDEA的自動補全功能非常強大,當你配置
<mvc:annotation-driven/>
後編譯器會幫你自動補全上面兩個配置檔案約束。這個時候如果你沒注意的就會爆出一個很莫名奇妙的錯:- 上面主要爆這個錯:九月 25, 2017 8:40:23 上午 org.apache.catalina.core.ApplicationContext log
資訊: Initializing Spring FrameworkServlet ‘springmvc’
九月 25, 2017 8:40:23 上午 org.apache.catalina.core.ApplicationContext log
嚴重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.interceptor.CacheInterceptor#0’: Cannot resolve reference to bean ‘cacheManager’ while setting bean property ‘cacheManager’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘cacheManager’ is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329).getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)。
報錯原因是:Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘cacheManager’ is defined
這裡主要是因為上面springmvc-servlet.xml配置檔案中由於IDEA自動配置啦cache,但配置檔案中又沒有指定快取的空間,JVM虛擬機器中也有個cacheManage,這就導致spring進行bean管理時掃描到兩個cache Manage 導致都不能正常載入,爆錯,而你在配置時明明沒有使用到快取,卻老是報一個快取的錯誤,實在很懵逼。
解決辦法
正確的配置檔案是這個樣子的
<?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="controller"/>
<mvc:annotation-driven/>
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
相關文章
- 記一次idea構建springmvc報錯:No bean named 'cacheManager' availableIdeaSpringMVCBeanAI
- No bean named 'xxx' is defined錯誤,原因及解決方案Bean
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- No bean named 'cacheManager' availablej 異常解決BeanAI
- spring getBean(String) No bean named '' is definedSpringBean
- Spring:錯誤No bean named 'xxxxxxx' availableSpringBeanAI
- 報錯:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is definedSpringFrameworkBeanException
- spring中No bean named xxx available錯誤SpringBeanAI
- idea maven搭建spring報錯:No bean named 'xxx' availableIdeaMavenSpringBeanAI
- 關於idea使用SpringMVC框架訪問WEB-INF中的檔案出現404報錯IdeaSpringMVC框架Web
- No Bean named 'Xxx' available 異常報錯BeanAI
- Intellij IDEA使用@Autowired註解,出現could not autowire錯誤,解決方案IntelliJIdea
- 使用 sudo 命令出現錯誤
- Maven專案報錯:No bean named 'xxxxxx' availableMavenBeanAI
- 使用idea搭建springMVCIdeaSpringMVC
- Ubuntu20.04安裝LabelImg 以及出現(ModuleNotFoundError: No module named libs.resources)錯誤UbuntuError
- No bean named ''XXX“ availableBeanAI
- No bean named BookServiceImpl availableBeanAI
- SpringMVC錯誤記錄SpringMVC
- The bean ‘xxx‘, defined in class path resource , ......Bean
- [轉載]使用IntelliJ IDEA開發SpringMVC網站(二)框架配置IntelliJIdeaSpringMVC網站框架
- 關於idea中使用註解開發springmvc 500報錯IdeaSpringMVC
- Laravel 出現 419 錯誤Laravel
- Opencv出現detecMultiScale錯誤OpenCV
- Caused by:.NoSuchBeanDefinitionException: No bean named 'userInfoServiceImpl' availableBeanExceptionAI
- Spring中出現:No bean named 'XXX' available問題解決SpringBeanAI
- spring配置檔案中配置了,但找不到Bean , 啟動不報錯,執行報錯No bean namedSpringBean
- springboot註解實現非同步呼叫時no bean of type TaskExecutor and no bean named 'taskExecutor' eitherSpring Boot非同步Bean
- 幽默:使用錯誤框架的下場框架
- eclipse用Maven構建SpringMVC環境報錯找不到springmvc包下的Dispatcher類EclipseMavenSpringMVC
- AS打包出現app:transformClassesAndResourcesWithProguardForRelease錯誤APPORM
- SSH出現Connection refused錯誤
- IDEA使用Gradle構建SpringBoot專案工程IdeaGradleSpring Boot
- 使用代理爬蟲出現407錯誤怎麼辦?爬蟲
- SpringMVC---IDEA 搭建SpringMVC工程SpringMVCIdea
- android 打包出現錯誤Error: ResourceNameAndroidError
- Flutter 最常出現的典型錯誤Flutter
- SpringBoot 學習之 No bean named ‘xxx’ availableSpring BootBeanAI