InitializingBean

来源:互联网 发布:硅谷大数据公司排名 编辑:程序博客网 时间:2024/05/29 23:23

//spring初始化bean的时候,如果bean实现了InitializingBean接口,会自动调用afterPropertiesSet方法

@Repository

public class SystemConfigData implements InitializingBean
{
    Logger logger = Logger.getLogger(this.getClass());



    public static String[] MEM_SERVERS;



    @Override
    public void afterPropertiesSet() throws Exception
    {
        try
        {
            Properties prop = new Properties();
            InputStream in = this.getClass().getResourceAsStream("/authconfig/authconfig.properties");
            prop.load(in);
          
            String memServersObj = prop.getProperty("mem_servers");       

        }
        catch (Exception e)
        {
            logger.error(e, e);
        }
    }


}
0 0
原创粉丝点击