java如何覆盖Spring启动库属性?
我想覆盖我在使用它的项目中编写的库属性。我正在使用这个关于创建库的Spring指南:https://spring.io/guides/gs/multi-module/
我想知道如何覆盖我的示例。使用“我的库”的项目中的属性文件
有可能吗
你可以在下面搜索框中键入要查询的问题!
我想覆盖我在使用它的项目中编写的库属性。我正在使用这个关于创建库的Spring指南:https://spring.io/guides/gs/multi-module/
我想知道如何覆盖我的示例。使用“我的库”的项目中的属性文件
有可能吗
# 1 楼答案
看来你不能。既然春天本身也不能
# 2 楼答案
取决于库属性文件指定属性的方式。如果首先从环境/系统中查找属性,则可以在代码中重写。如果是硬编码,则不是。 例如:
您可以在代码中设置
ENV_VAR
环境变量或env-var
系统变量来覆盖prop
的值。如果没有,将使用默认值abc
# 3 楼答案
不要添加应用程序。属性文件到库中。它可能会引起很多问题。如果要设置默认属性,请执行以下操作:
每个应用程序都应该在自己的应用程序中为自己配置库值。属性文件
# 4 楼答案
Spring Boot属性顺序优先级如下所述:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
从链接:
那么顺序是1-17。例如,列表中的4(命令行参数)覆盖列表中的15(application.properties文件),依此类推