Как использовать строки, содержащие специальные символы, в качестве ключей в YAML с помощью MicronautJAVA

Программисты JAVA общаются здесь
Гость
Как использовать строки, содержащие специальные символы, в качестве ключей в YAML с помощью Micronaut

Сообщение Гость »


My application.yaml is like so:

Код: Выделить всё

env:   emails:     a: 0 # works, the rest don't     b.com: 0     c.com: 1     "d.com": 0     'e.com': 1     "[f.com]": 0     '[g.com]': 1 
I am using this class to read it:

Код: Выделить всё

@ConfigurationProperties("env") public class Configurator {   private Map emails;   public Map getEmails() {     return emails;   }   public void setEmails(       @MapFormat(keyFormat = StringConvention.RAW) Map emails) {     this.emails = emails;   } } 

Код: Выделить всё

Map emails
only contains one entry: . How do I get keys that are strings containing special characters to map correctly?

I've already tried

Код: Выделить всё

@MapFormat(keyFormat = StringConvention.RAW)
in the setter function.

Alternatively, this

Код: Выделить всё

application.yml
format works for me - but I'm not sure how I can bind it directly to a using

Код: Выделить всё

@ConfigurationProperties
without using a

Код: Выделить всё

TypeConverter
.

Код: Выделить всё

env:   emails:     - key: a.com     - value: 0 


Источник: https://stackoverflow.com/questions/781 ... h-micronau

Вернуться в «JAVA»