
io.github.hengyunabc.bind.SpringBoot1Binder Maven / Gradle / Ivy
The newest version!
package io.github.hengyunabc.bind;
import org.springframework.boot.bind.PropertySourcesPropertyValues;
import org.springframework.boot.bind.RelaxedDataBinder;
import org.springframework.core.env.ConfigurableEnvironment;
public class SpringBoot1Binder extends AbstractBinder {
@Override
public T bind(ConfigurableEnvironment environment, String prefix, Class type) {
T instance;
try {
instance = type.newInstance();
} catch (Throwable e) {
throw new IllegalArgumentException(e);
}
new RelaxedDataBinder(instance, prefix)
.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
return instance;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy