String resolvedLocation = this.environment.resolveRequiredPlaceholders(location); Resource resource = this.resourceLoader.getResource(resolvedLocation); addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
String resolvedLocation = this.environment.resolveRequiredPlaceholders(location); Resource resource = this.resourceLoader.getResource(resolvedLocation); addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));
@Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { ResourceLoader resourceLoader = application.getResourceLoader(); if (resourceLoader == null) { resourceLoader = new DefaultResourceLoader(); } MutablePropertySources propertySources = environment.getPropertySources(); for (String location : DEPRECATED_LOCATIONS) { try { Resource resource = resourceLoader.getResource(location); PropertySource<?> propertySource = DEFAULT_PROPERTY_SOURCE_FACTORY.createPropertySource(null, new EncodedResource(resource)); if (propertySources.contains(propertySource.getName())) { propertySources.replace(propertySource.getName(), propertySource); } else { propertySources.addLast(propertySource); } logger.warn("Using deprecated property source {} please switch to using Spring Boot externalized configuration", propertySource); } catch (IllegalArgumentException | FileNotFoundException | UnknownHostException ex) { // We are always ignoring the deprecated resources. This is done in the same way as in the Spring ConfigurationClassParsers // Placeholders not resolvable or resource not found when trying to open it if (logger.isInfoEnabled()) { logger.info("Properties location [{}] not resolvable: {}", location, ex.getMessage()); } } catch (IOException ex) { throw new UncheckedIOException("Failed to creaty property source", ex); } } }
String resolvedLocation = this.environment.resolveRequiredPlaceholders(location); Resource resource = this.resourceLoader.getResource(resolvedLocation); addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding)));