什么时候用bootstrap2.properties
时间: 2023-10-24 20:07:12 浏览: 42
Bootstrap2.properties 是一个 Spring Boot 2.x 版本之前使用的配置文件,在 Spring Boot 2.x 版本之后,被 application.properties 或 application.yml 所取代。因此,除非你使用的是 Spring Boot 2.x 版本以下的版本,否则不需要使用 Bootstrap2.properties 文件。
相关问题
同时存在bootstrap.properties和bootstrap2.properties时该用哪个
如果同时存在 `bootstrap.properties` 和 `bootstrap2.properties`,则应该使用 `bootstrap.properties`。这是因为 Spring Boot 默认会加载名为 `bootstrap.properties` 的配置文件,而不是 `bootstrap2.properties`。如果需要覆盖 Spring Cloud Config 服务器的配置,可以在应用程序的 `bootstrap.properties` 文件中指定。如果需要使用不同的配置文件名,则可以通过设置 `spring.cloud.config.name` 属性来实现。例如,将其设置为 `myconfig` 将会加载 `myconfig.properties` 或 `myconfig.yml` 文件。
bootstrap.properties,bootstrap.yml的优先级顺序
在Spring Boot应用程序中,bootstrap.properties和bootstrap.yml是用于配置Spring Cloud Config服务器连接属性的文件。这两个文件的优先级顺序如下:
1. bootstrap.properties:这是最基本的配置文件,如果存在,则其属性将覆盖其他属性。
2. bootstrap.yml:如果没有找到bootstrap.properties,则会查找bootstrap.yml。如果在两个文件中都定义了一个属性,则bootstrap.properties中的属性将覆盖bootstrap.yml中的属性。
3. 配置服务器中的属性:如果找不到任何属性文件,则应用程序将从配置服务器中获取属性。如果在这里定义了属性,则它将覆盖任何其他属性。
总之,bootstrap.properties和bootstrap.yml是用于配置Spring Cloud Config服务器连接属性的文件。它们的优先级顺序是bootstrap.properties > bootstrap.yml > 配置服务器中的属性。