有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么要使用@PropertySource而不是PropertyPlaceHolderConfigure?

SpringJavadoc中:

"existing configuration makes use of the "systemPropertiesMode" and/or "systemPropertiesModeName" properties. Users are encouraged to move away from using these settings, and rather configure property source search order through the container's Environment"

为什么鼓励搜索集装箱的环境

编辑:

需要了解为什么使用@PropertySource而不是PropertyPlaceHolderConfigure,如果两者都实现了路径中提到的获取资源的目标,那么PropertySource比PropertyPlaceHolderConfiger有什么好处


共 (1) 个答案

  1. # 1 楼答案

    我想这是因为规则#3 of 12 factor app principles

    The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard.