在配置文件级别上说明默认属性

问题描述 投票:0回答:1
设置,但它加载了这些属性

application-(profile) - (profile)。我想在我的项目中指定

默认文件 - (配置文件)。除了能够加载这些附加的特定于特定配置文件的默认值之外 我该怎么做? Google和Chatgpt都没有任何帮助。 也许有一种更简单的方法,但这是想到的: 在您的库中定义属性文件 - 例如default-properties.yml

spring-boot
1个回答
0
投票

在您的库中定义了导入的配置文件:
  1. default-properties.yml
在您的客户端项目中(具有该库作为依赖关系,导入配置):
  1. @Configuration @PropertySource("classpath:default-properties.yml") public class PropertiesConfig { }
    现在,如果您的客户端项目未定义属性
  2. @Import(PropertiesConfig.class) @SpringBootApplication public class FooApplication {}
默认值为
some-property
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.