- Hands-On Enterprise Java Microservices with Eclipse MicroProfile
- Cesar Saavedra Heiko W. Rupp Jeff Mesnil Pavol Loffay Antoine Sabot Durand Scott Stark
- 97字
- 2021-06-24 12:56:22
Built-in converters
The MicroProfile Config implementation provides built-in converters for the primitive types (boolean, int, long, byte, float, and double) and their corresponding Java types (for example, Integer).
It also provides support for arrays in the property value using the "," as the item separator. If the "," must be part of an item, it must be escaped with a backslash "\":
private String[] pets = config.getValue("myPets", String[].class)
If the value of the myPets property is dog,cat,dog\\,cat, the elements of the array stored in pets would be {"dog", "cat", "dog,cat"}.