0

How can I have spring create a default configuration file for the end user if it does not exist at the target location. I would like this configuration file to be mapped to a bean after it has been created. I've searched the internet for spring tutorials but I have been unable to find one that demonstrates this.

I would like to have a system that does the following:

  1. Scans for configuration beans
  2. Checks if the configuration file exists on the file system
  3. Writes configuration defaults to the file if it does not exist
  4. Maps the values to the configuration bean
Ashley
  • 142
  • 7
  • What exactly do you mean by configuration file? Do you mean the `application.properties`/`application.yml`? – Turing85 Aug 06 '23 at 22:37
  • No i mean an external configuration file. One that the end user can configure – Ashley Aug 06 '23 at 22:38
  • The end user can always provide a `application.properties`/`application.yml` that overrides the packaged one. Aside from this, we also have the possibility to bind configuration properties to environment variable, which the end user can set to configure the application. – Turing85 Aug 06 '23 at 22:40
  • I would like to have all configuration files generated at the first time the program runs rather than having the end user provide the configuration file or packaging it along side the end program. Like in cases where the user deletes the configuration file, It would write the configuration defaults – Ashley Aug 06 '23 at 22:45

0 Answers0