Make Java Properties available across classes?

前端 未结 8 2254
情深已故
情深已故 2020-12-30 08:16

I chose to take properties file for customization of some settings. I use the following code to make a Properties Object available in a class

Properties defa         


        
8条回答
  •  滥情空心
    2020-12-30 08:44

    Rather than loading properties in every class. Load it somewhere around main() and pass it to other classes via their constructors.

    Don't share them globally. - Difficult to test - Against the abstraction (Global access, DAO can access user settings. it should be prevented by passing only what it needs.. not everything) - Classes lie what they need

提交回复
热议问题