鍍金池/ 問答/Java  HTML/ Spring xml bean配置文件中如何配置一個bean 是可選的optio

Spring xml bean配置文件中如何配置一個bean 是可選的optional

如何設置bean是非必需的

  • 工程中messageSource這個bean是非必需的,要求messageSource注入失敗時,Spring容器也能啟動,Spring的xml配置文件中有這種選項嗎,或者有其它方法解決這個問題嗎?先多謝啦!
<bean id="messageSource"  class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:i18n/messages" />
    <property name="defaultEncoding" value="UTF-8"/>
</bean>
回答
編輯回答
青瓷

好像并沒有這種配置,如果不用的話,只要保證bean對應的class存在應該就沒什么問題了吧

2017年6月13日 03:32