I have a YAML configuration file with a map of properties:
properties:
a.b.c: 1
Boot will parse this as:
{a:{b:{c:1}}}
However, what I desire is :
{'a.b.c': 1}
Is there anyway to coax it into "pass through" key mode? Quoting the key doesn't seem to help.
Actual example below.
import static com.google.common.collect.Maps.newLinkedHashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import lombok.Data;
import lombok.val;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties("hadoop")
public class HadoopProperties {
private Map<Object, Object> properties = newLinkedHashMap();
}
application.yml
:
hadoop:
properties:
fs.defaultFS: hdfs://localhost:8020
mapred.job.tracker: localhost:8021
Calling toString()
on the resulting object:
HadoopProperties(properties={fs={defaultFS=hdfs://localhost:8020}, mapred={job={tracker=localhost:8021}}})
I see. It's because you are binding to a very generic object, so Spring Boot thinks your period separators are map key dereferences. What happens if you bind to Map or Properties?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With