上QQ阅读APP看书,第一时间看更新
Using converters for high-level configuration
MicroProfile Config will read Java String objects from its ConfigSource. However, it provides facilities to convert these String objects into more specific types in your application.
For example, the myUrl field we described previously is a URL object. The corresponding property, my.url, is read as a String object and then converted into a URL object before it is injected.
If the application uses the Config object, the MicroProfile Config implementation will also convert the String object into the type passed as the second argument of the getValue and getOptionalValue methods. This conversion can be done using different converter types: built-in, automatic, and custom. We will talk about them in detail now.