Add support for RelaxedDataBinder aliases
Update RelaxedDataBinder to support property aliases and change DataSourceBuilder to use them. Fixes gh-1384
This commit is contained in:
@@ -23,7 +23,6 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.boot.bind.RelaxedDataBinder;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -84,15 +83,8 @@ public class DataSourceBuilder {
|
||||
}
|
||||
|
||||
private void bind(DataSource result) {
|
||||
new RelaxedDataBinder(result).bind(getPropertyValues());
|
||||
}
|
||||
|
||||
private PropertyValues getPropertyValues() {
|
||||
if (getType().getName().contains("Hikari") && this.properties.containsKey("url")) {
|
||||
this.properties.put("jdbcUrl", this.properties.get("url"));
|
||||
this.properties.remove("url");
|
||||
}
|
||||
return new MutablePropertyValues(this.properties);
|
||||
MutablePropertyValues properties = new MutablePropertyValues(this.properties);
|
||||
new RelaxedDataBinder(result).withAlias("url", "jdbcUrl").bind(properties);
|
||||
}
|
||||
|
||||
public DataSourceBuilder type(Class<? extends DataSource> type) {
|
||||
|
||||
Reference in New Issue
Block a user