Hello. I can't seem to figure out how app configuration in Spring works.
I have a file app_config.json contained somewhere within the machine's filesystem. I have to get the path to that file from the environment var APP_CONFIG_FILE. I also want to have a similar copy of that file inside the project, which should be default when APP_CONFIG_FILE isn't defined or empty. I want to read the json from file and parse it into class AppConfiguration and have it accessible with DI.
The thing is I can't figure out where to start. The more articles i read, the more confused i become. So any help (some advice or examples) would be much appreciated!
#Spring configuration with external file
11 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @brisk rock! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
I mean, Spring provides solutions, and you're essentially responding, "no, we'll use my thing instead, even though it doesn't provide any sort of benefits, I just like it better"
Spring most likely allows this anyway, but it is to be expected that only core Spring developers would know how, considering it doesn't have any real use
It's just that i have the same logic implemented for another service in asp.net. I just thought it would be easier to get started with what i had prior. What would be the better way?
standardization. Use a .properties or .yaml file, as spring configuration examples provide.
But, again, it's most likely doable the way you want. It's just, nobody is going to publish tutorials for what could be useful to you and to nobody else
Okay, but can i do it the Spring way but with a json file? I really don't want to change the file because other service use it.
Like I said, most likely. It's just, there is nothing surprising about how it's hell to find information on how to do it
In fact, worse coming to worst, you could probably handle it all in the public static void main before starting spring engine
Okay I'll keep looking for solutions, thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.