SpringBoot2 ConfigurationProperties removes colon from yaml keys
See original GitHub issueUntil SpringBoot 1.5.9 I was using the application yaml to define a namespaced id with few properties. eg.
app:
ids:
"urn:test:id:12-34" :
roles:
- CREATE
- ALLOW_ALL
"urn:test:id:23-41" :
roles:
- DELETE
- ALLOW_ALL
This was being read in as a Map
@ConfigurationProperties(prefix = "app")
@Data
@Component
public class IdProps {
@Data
public static class IdProps {
private Map<String, Id> ids = new HashMap<>();
}
@Data
public static class Id {
private List<String> roles = new ArrayList<>();;
}
}
The expectation was that this worked in SpringBoot2.
However, the Map keys in SPringBoot2 were as below “urntestid12-34” -> “IdProps.Id(roles=[CREATE, ALLOW_ALL])”
Expected behavior “urn:test🆔12-34” -> “IdProps.Id(roles=[CREATE, ALLOW_ALL])”
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Escaping a dot in a Map key in Yaml in Spring Boot
As a work around, you can use Spring's YamlMapFactoryBean to create a Yaml Map as it is. Then, you can use that map...
Read more >Core Features - Spring
This section dives into the details of Spring Boot. Here you can learn about the key features that you may want to use...
Read more >YAML to List of Objects in Spring Boot - Baeldung
Spring Boot provides the @ConfigurationProperties annotation to simplify the logic of mapping external configuration data into an object model.
Read more >Spring @ConfigurationProperties using YAML
In general, you do not need to use quotation "" around string values in YAML. Quotation is requires if it: includes a colon...
Read more >Spring Boot @ConfigurationProperties example - Mkyong.com
properties or yml file below, how we are going to map the values via @Value ? application.properties. #Logging logging.level.org.springframework ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@balajeetm the new properties binder strips off all characters that are not alphanumeric or
-so that properties can be read in a uniform manner. For map keys that have special characters in them, you can surround the key name with[]so that the key gets used as specified, for example,'[urn:test:id:12-34]'.Thanks for your quick feedback… I’ll take a deeper look in your referenced issue and then proceed accordingly.