Duplicated InterceptorRegistry bean definitions Error

Micronaut v3.4.1 has bug that duplicate interceptorRegistry beans registered.

[Huang Li] 09/08/2022

This issue happens when the Micronaut version indicated in gradle.properties file is different from the version actually used in service module. The indication tells dependencies (like flyaway) to look for indicated version of Micronaut, not for gradle to download or base on that version.

Replicate:

  1. Change micronautVersion in gradle.properties to any version different from actual running version

    1. eg. customer_manager is using v3.4.3, but gradle.properties indicates v3.4.2

  2. run with “./gradlew run” then you will see the error

Solution:

Always indicate Micronaut version in gradle.properties to the currently running one in service project.

ie. If the version used to run is 3.4.3, then make sure micronautVersion=3.4.3 in gradle.properties as well.

Notice that every service project is using different versions of Micronaut;

Inside each project, each library version is also diverged. eg. micronaut.applications=3.5.1, etc.

Or exclude the unexpected version of micronaut:

implementation("ph.safibank.common:utils:2.+") {
    exclude(group = "io.micronaut")
}

Micronaut built-in HttpClient GET returns empty body

httpClient.toBlocking().exchange(getRequest)

This method call returns empty HTTP body. Use below instead:

httpClient.toBlocking().exchange(getRequest, bodyType)

Attachments: