- Hands-On Enterprise Java Microservices with Eclipse MicroProfile
- Cesar Saavedra Heiko W. Rupp Jeff Mesnil Pavol Loffay Antoine Sabot Durand Scott Stark
- 87字
- 2021-06-24 12:56:22
Automatic converters
MicroProfile Config also defines automatic converters. If a converter is not known for a given Java type, it will attempt to convert a String object into it using any one of the three different approaches:
- The Java type has a public constructor with a String parameter.
- It has a public static valueOf(String) method.
- It has a public static parse(String) method.
That's how the my.url property was converted from String into URL since the java.net.URL type has the public URL(String) constructor.