|
31 | 31 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
32 | 32 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
33 | 33 | import org.springframework.boot.SpringApplication;
|
34 |
| -import org.springframework.boot.bind.PropertySourcesPropertyValues; |
35 |
| -import org.springframework.boot.bind.RelaxedDataBinder; |
| 34 | +import org.springframework.boot.bind.PropertiesConfigurationFactory; |
36 | 35 | import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
|
37 | 36 | import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
38 | 37 | import org.springframework.boot.env.EnumerableCompositePropertySource;
|
|
54 | 53 | import org.springframework.core.io.ResourceLoader;
|
55 | 54 | import org.springframework.util.Assert;
|
56 | 55 | import org.springframework.util.StringUtils;
|
| 56 | +import org.springframework.validation.BindException; |
57 | 57 |
|
58 | 58 | /**
|
59 | 59 | * {@link ApplicationListener} that configures the context environment by loading
|
@@ -171,9 +171,17 @@ protected void addPropertySources(ConfigurableEnvironment environment,
|
171 | 171 | */
|
172 | 172 | protected void bindToSpringApplication(ConfigurableEnvironment environment,
|
173 | 173 | SpringApplication application) {
|
174 |
| - RelaxedDataBinder binder = new RelaxedDataBinder(application, "spring.main"); |
| 174 | + PropertiesConfigurationFactory<SpringApplication> binder = new PropertiesConfigurationFactory<SpringApplication>( |
| 175 | + application); |
| 176 | + binder.setTargetName("spring.main"); |
175 | 177 | binder.setConversionService(this.conversionService);
|
176 |
| - binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources())); |
| 178 | + binder.setPropertySources(environment.getPropertySources()); |
| 179 | + try { |
| 180 | + binder.bindPropertiesToTarget(); |
| 181 | + } |
| 182 | + catch (BindException e) { |
| 183 | + throw new IllegalStateException("Cannot bind to SpringApplication", e); |
| 184 | + } |
177 | 185 | }
|
178 | 186 |
|
179 | 187 | /**
|
|
0 commit comments