messageSource
コンポーネントクラスの 1 つに Beanを注入しようとしています。
以下は Bean xml の一部です。
<context:annotation-config />
<context:component-scan base-package="com.mattis.test"/>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
そして、私のコンポーネントではこれを持っています:
@Component
public class TestClass {
@Autowired
private MessageSource messageSource;
<-- more code goes here -->
}
TestClass をインスタンス化するときは常に、messageSource は null です。Bean xml とクラス構成をさらに試しましたが、どれも機能しませんでした。