3

i'm trying to inject a list of object in quarkus but I receive an error "No Converter registered for class ExternalApiParam".

My yaml is:

custom:
  external-api-list:
    - name: example-1
      uri: https://run.mocky.io/v3/55402172-82c3
    - name: example-2
      uri: https://run.mocky.io/v3/13417375-a19c

My config class is:

@ConfigProperties(prefix = "custom")
@Data
public class ExternalApiConfigProperties {

    List<ExternalApiParam> externalApiList;
}

What do I wrong?

mraf4
  • 106
  • 6

1 Answers1

0

You need to provide a Config Converter class that can read the configuration value and convert it to your object.

Please check here for an example: https://github.com/smallrye/smallrye-config/blob/master/sources/yaml/src/test/java/io/smallrye/config/source/yaml/YamlConfigSourceTest.java#L141-L153

And how to use Converters: https://quarkus.io/guides/config#custom-configuration-converters

Roberto Cortez
  • 803
  • 4
  • 8
  • it works but when I package for native runner it does not work. I receive this error " Cannot create property=externals-api-list for JavaBean=ExternalApiParams(externals-api-list=null)". Do you have any suggestions? – mraf4 Dec 02 '20 at 15:16
  • Can you provide more context? – Roberto Cortez Dec 03 '20 at 01:38
  • I used this approach in my quarkus application in jar mode and it works. When I try to package my application in native mode it does not work. Maybe @ConfigMapping causes issues in native mode with quarkus? – mraf4 Dec 03 '20 at 09:16
  • It it is causing issues, then it is a bug. Are you able to provide me with a reproducer? Thanks! – Roberto Cortez Dec 03 '20 at 11:46