简体   繁体   中英

Store Static Data in DB or Spring yml Property File

I have some static configurations that will not be changed for each environment, for example, the mapping between client names and their id. In this case, should I store them in a Spring yml property file or in a database, eg. mongoDB, so that they can be easily accessed via Java code?

It better keep in spring yaml instead of storing in any Database. Because calling the IO operations little expensive. Keeping static code in yaml or properties file will faster to access.

From the one side, consider that when you are adding a database component, you are adding additional potential point of failure to your app. What will happen if DB will not be accessible, for any reason? ( crashed, under maintenance, network issues )?

From the second side, it depends how exactly your implementation will be using files. For example, if you will be adding items in your mapping between clients/ids, will you need to restart/rebuild/redeploy your app? How many running instances of your app will you have?

So, there are no one exact answer for all cases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM