Make Java Properties available across classes?

前端 未结 8 2251
情深已故
情深已故 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:43

    This is a special case of making anything available globally. Using static methods is quite bad. A better but bad solution is using the sigleton pattern. Testing is the greatest problem here. IMHO, the best way is using Dependency injection, although it may be an overkill for small applications.

提交回复
热议问题