Spring读取配置文件

来源:互联网 发布:小米5刷机端口被关闭 编辑:程序博客网 时间:2024/05/22 13:19

Spring的配置:
 <!--读取配置文件 -->    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">        <property name="basenames">            <list>                <!--<value>resources/router</value>-->                <value>mini_adapter</value>            </list>        </property>    </bean>

@Component("PropertyReader")
public class PropertyReader {
@Resource
private MessageSource messageSource;


public String getValue(String key) {
return getValue(key, null);
}


public String getValue(String code, String message, Object... argument) {
return messageSource.getMessage(code, argument, message, Locale.getDefault());
}
}

0 0