Say, application.yml and a configuration class of the Spring Boot app look like the following
application.yml
conv:
map:
ė: e
ü: u
somekey: somevalue
###other properties omitted for brevity
Config.java
package foo.bar;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "conv")
public class Config {
private Map<String, String> map = new HashMap<>();
/*other properties*/
}
At runtime the map property is not populated with all 3 entries. It is the last map entry (somekey: somevalue) that ends up in the map. It is also the same entry whose key doesn’t have extended latin characters such as ė and ü.
However, if keys and values for the first two map entries were to be swapped like this
conv:
map:
e: ė
u: ü
somekey: somevalue
the resulting map would contain exactly three records, which brings the question – how to deal with extended latin characters if I still want to preserve them as keys in the map?