how to read properties file in spring project?

后端 未结 5 1373
梦谈多话
梦谈多话 2020-12-06 01:28

Before post this Question, I google to get Properties from Spring project(Its NOT web-based project). I am confused as every one are talking about application-context.xml an

5条回答
  •  时光说笑
    2020-12-06 01:48

    You don't have to use Spring. You can read with plain java like this:

    Properties properties = new Properties();
    properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName));
    

提交回复
热议问题