Externalize configuration Akka

随声附和 提交于 2019-12-25 00:13:52

问题


I am new in Akka and I faced the problem below.

I want to externalize the configuration in my App. More specifically, I have some variables that are different per each environment. So I think that I can have specific environment variables (secrets, etc) for each environment. But what I can do with some variables (non-secrets) which are different per each environment?

What is the difference between, dev.properties, application.conf, deploy.json files? What is the proper way to load variables from those files?


回答1:


There's a few options:

  • Environment variables and using the support for substitution (there is also support for having default in the file and only use the environment vars if they are set). - https://github.com/lightbend/config#optional-system-or-env-variable-overrides
  • System properties, if you set a system property when you start the JVM, and that system property matches a path in the config file, it overrides the setting
  • You can point to an alternative application.conf file using a system property - https://github.com/lightbend/config#standard-behavior

If that is not enough you could also do completely custom logic around selecting logic by programmatically creating a Config instance and passing that to the ActorSystem when you create it.

The dev.properties and deploy.json is AFAIK not related to Akka, unless something specifically done in your application.



来源:https://stackoverflow.com/questions/49978999/externalize-configuration-akka

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!