contexto de la nube de primavera
Usando SpringBoot solo, descubrí que el archivo bootstrap.properties no surtirá efecto.
Después de ver el código fuente, resulta que Spring Boot en sí no lo admite, y se requiere que Spring Cloud surta efecto.
El código específico se implementa en org.springframework.cloud.bootstrap.BootstrapApplicationListener en el paquete spring-cloud-context
ApplicationListener
Cuanto menor sea el pedido, más avanzado
ConfigFileApplicationListener
int HIGHEST_PRECEDENCE = Integer.MIN_VALUE;
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
// -2147483638
private int order = DEFAULT_ORDER;
BootstrapApplicationListener
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 5;
// -21474836343
private int order = DEFAULT_ORDER;
sping.factories
# Application Listeners
org.springframework.context.ApplicationListener=\
org.springframework.cloud.bootstrap.BootstrapApplicationListener,\
org.springframework.cloud.bootstrap.LoggingSystemShutdownListener,\
org.springframework.cloud.context.restart.RestartListener
bootstrap.properties
org.springframework.cloud.bootstrap.BootstrapApplicationListener
public static final String BOOTSTRAP_PROPERTY_SOURCE_NAME = "bootstrap";
String configName = environment
.resolvePlaceholders("${spring.cloud.bootstrap.name:bootstrap}");
Map<String, Object> bootstrapMap = new HashMap<>();
bootstrapMap.put("spring.config.name", configName);
# 那怕配置spring.cloud.bootstrap.name,这里也是bootstarp
bootstrapProperties.addFirst(
new MapPropertySource(BOOTSTRAP_PROPERTY_SOURCE_NAME, bootstrapMap));
Otros atributos
String configLocation = environment
.resolvePlaceholders("${spring.cloud.bootstrap.location:}");
String configAdditionalLocation = environment
.resolvePlaceholders("${spring.cloud.bootstrap.additional-location:}");
# spring.cloud.bootstrap.enabled
ConfigurableEnvironment environment = event.getEnvironment();
if (!environment.getProperty("spring.cloud.bootstrap.enabled", Boolean.class,
true)) {
return;
}