相关疑难解决方法(0)

Spring @Autowired messageSource在Controller中工作但在其他类中没有?

新更新:2010年12月31日下午8:15
非常脏修复,但这是我暂时使messageSource工作的方式.我更改了我的Controller类,将'messageSource'传递给Message类,并且能够检索消息.请查看下面的课程定义,让我们了解您可能需要提供帮助的更多信息.我非常感谢您提供的所有帮助.

2010年12月31日下午3点
由于无法通过注释成功配置messageSource,我尝试通过servlet-context.xml配置messageSource注入.我仍然将messageSource设为null.如果您需要更具体的信息,请告诉我,我会提供.感谢您的帮助.

servlet-context.xml
<beans:bean id="message"
    class="com.mycompany.myapp.domain.common.message.Message">
    <beans:property name="messageSource" ref="messageSource" />
</beans:bean>
Run Code Online (Sandbox Code Playgroud)

Spring提供了有关spring初始化的以下信息.

INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning

INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'message': replacing [Generic bean: class [com.mycompany.myapp.domain.common.message.Message]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\springsource\tc-server-developer-2.1.0.RELEASE\spring-insight-instance\wtpwebapps\myapp\WEB-INF\classes\com\mycompany\myapp\domain\common\message\Message.class]] with [Generic bean: class [com.mycompany.myapp.domain.common.message.Message]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]]

INFO : …
Run Code Online (Sandbox Code Playgroud)

java spring annotations

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

annotations ×1

java ×1

spring ×1