Skip to main content

Autoconfiguration

This section shows how to set up autoconfiguration using two methods.

Using Annotation

To set up autoconfiguration, just use the @EnableExchangeClients annotation. This works like @EnableFeignClients and tells the framework where to find HttpExchange clients, then registering them as beans.

By default, it looks for clients in the same package as the annotated class.

  • Specifying basePackages:

    @EnableExchangeClients(basePackages = "com.example")
    info

    If you specify packages with basePackages, it will only look in those packages, not the one with the annotated class.

  • Specifying clients:

    @EnableExchangeClients(clients = {PostApi.class, UserApi.class})
    info

    This is quicker than basePackages because it doesn't have to scan the classpath.

  • Combining basePackages with clients:

    @EnableExchangeClients(basePackages = "com.example", clients = {PostApi.class, UserApi.class})

Using Configuration

If you don't want to use annotations, you can set up using configuration.

application.yml
http-exchange:
base-packages: com.example
clients:
- com.foo.PostApi
- com.bar.UserApi
info

If you use both the annotation and config file, the settings from the annotation are used first.