Декларативный REST-клиент Micronaut выдает ошибку - отсутствует перехватчик метода @Introduction

Когда я автоматически подключаю клиентский интерфейс к декларативному клиенту Micronaut, я получаю следующую ошибку:

Caused by: java.lang.IllegalStateException: At least one @Introduction method interceptor required, but missing. Check if your @Introduction stereotype annotation is marked with @Retention(RUNTIME) and @Type(..) with the interceptor type. Otherwise do not load @Introduction beans if their interceptor definitions are missing!
    at io.micronaut.aop.chain.InterceptorChain.resolveIntroductionInterceptors(InterceptorChain.java:194)
    at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1494)

Как правильно это исправить?

Детали

У меня есть установленное приложение Grails, которое я недавно обновил с 3.x до 4.0.1.

В этом приложении есть служба, которая выполняет несколько вызовов REST параллельно, и я пытаюсь добавить новый вызов REST, который использует новый декларативный клиент Micronaut HTTP.

Я добавил клиентскую библиотеку в dependencies в build.gradle:

    compile "io.micronaut:micronaut-http-client"

Мой клиентский интерфейс выглядит так (в src/main/groovy):

package com.mycompany.xyz.rest

import com.mycompany.xyz.rest.myendpoint.Results
import io.micronaut.http.annotation.Get
import io.micronaut.http.annotation.Header
import io.micronaut.http.client.annotation.Client

@Client('xyzRest')
@Header(name = 'myauthkey', value = '${myAuthKey}')
interface XyzRestClient {
    @Get('/myendpoint')
    Results myendpoint(String param1, String param2)
}
package com.mycompany.xyz.rest.myendpoint

import com.mycompany.xyz.rest.myendpoint.DataItem
import groovy.transform.CompileStatic

@CompileStatic
interface Results extends List<DataItem> {
}

Я настроил URL в application.yml:

environments:
    development:
        micronaut:
            http:
                services:
                    xyzRest:
                        urls:
                            - http://xyz.mycompany.com/rest/v1

Сообщение о @Introductionзаставляет меня думать, что Micronaut не выполняет процесс компиляции декларативного клиента. Есть ли

Что еще мне не хватает?

Обновить:

Я попытался изменить build.gradle зависимость от implementation как показано в документации Micronaut, вместо compile, как показано в документации Grails. Никаких кубиков.

Обновление 2:

Я обнаружил, что конструктор для HttpClientIntroductionAdviceникогда не вызывается при запуске. Я не знаю, почему он не включен в мой проект. IntelliJ показываетmicronaut-http-client:1.1.4 во внешних библиотеках, и он установлен на compile объем.

1 ответ

А gradlew clean похоже, решил проблему.

Я пытался работать в обратном направлении и продублировать проблему для потомков, но пока не смог.

Другие вопросы по тегам