我試圖使用@Scope註釋更改bean的作用域。該bean實際上是作爲MessageSource工作並用於國際化目的。將會話作用域應用於bean的錯誤
在MVC-dispacher-servlet.xml文件中的模式如下:在控制檯中所述
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
例外如下:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [scoped-proxy]
您帖子中的信息不足。你的bean是替換默認的消息源,只是使用它還是一個正常的bean做類似的事情? – 2013-03-17 06:25:12
@Martin:這是一個普通的bean,但內部它有權訪問通過其實現i18n的消息源,而不是在每個methd調用中傳遞區域設置我聲明瞭一個變量webLocale到捕獲的同時登錄,這將是一個常量參數,它將在調用messageource的getMessage()方法時傳遞 – Prashant 2013-03-17 06:31:39