I have many classes with static final fields which are used as default values or config. What is best approach to create global config file? Should I move these fields to single
Y,es properties file is always preferable for configuration. There are multiple ways to read it, one being apache commons-configuration.
If the properties are environment-dependent, externalize them (outisde the project), and set the path to them (for example with -Dconfig.location=..
). If they don't change depending on the environment, simply put the properties file on the classpath.
See this article of mine about the envioronment-dependent properties.
Then, you can have a static
holder for the Properties
/ Configuration
/ ... object, or, if possible, inject (if using a DI framework) the values wherever they are needed.