0

I have a java spring project that contains property files. In the file, there are lots of folder path definitions. But these path are Linux paths. i.e. /home/share/Document. I would like to develop the project under both Linux and Windows so I have created a network share that I can access Linux file under Window environment. However, I have to add a prefix in front of the Linux path such as \network\...\home\share\Document in order to make the path work.

What is the standard/normal way to handle this? I can image I should have two environment property files. For example, one is called DEV_unix.properties and the other is call DEV_win.properties. But this doesn't look perfect.

Could someone share his/her insights please ?

Guifan Li
  • 1,543
  • 5
  • 14
  • 28
  • Yes should have two environment files and when running the spring app you should pass the env as parameter on the command line or run params – muasif80 Sep 20 '19 at 01:21
  • Why not just put both paths in your properties file, then select one as needed by detecting the current operating system? Maybe use something like [this](https://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java) to find that information. – Avi Sep 20 '19 at 01:42

1 Answers1

0

You can use profile in this case. Set active profile in your application.{profile}.properties. You can set this profile as a environment variable or VM arguments so that you need to set the environment variable in different machines based on the Operating system. You can check the below link for more details. Springboot not loading application.dev.properties file

Sujay Mohan
  • 933
  • 7
  • 14