FXmain.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:bd-codes 作者:
public static void iocStart() {
    // BeanFactory方式启动
    ConfigurableListableBeanFactory beanFactory = new XmlBeanFactory(
            new ClassPathResource("spring.xml"));

    // 读取外部properties文件属性值填充xml中的bean,property
    PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
    propertyPlaceholderConfigurer.setLocation(new ClassPathResource(
            "config.properties"));
    // 应用postProcessBeanFactory
    propertyPlaceholderConfigurer.postProcessBeanFactory(beanFactory);

    // 读取外部properties文件,覆盖xml中bean指定的property值
    PropertyOverrideConfigurer propertyOverrideConfigurer = new PropertyOverrideConfigurer();
    propertyOverrideConfigurer.setLocation(new ClassPathResource(
            "spring-adjustment.properties"));
    propertyOverrideConfigurer.postProcessBeanFactory(beanFactory);

    // CustomEditorConfigurer,对bean的property值,做类型转换支持
    CustomEditorConfigurer customEditorConfigurer = new CustomEditorConfigurer();
    Map customEditors = new HashMap();
    customEditors.put(Date.class, new DatePropertyEditor());
    customEditorConfigurer.setCustomEditors(customEditors);
    customEditorConfigurer.postProcessBeanFactory(beanFactory);

    FXNewsProvider newsProvider = (FXNewsProvider) beanFactory
            .getBean("newsProvider");
    System.out.println(newsProvider.getClientId());
    System.out.println(newsProvider.getBaseUrl());
    System.out.println(newsProvider.getAddDate().toLocaleString());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号