Home > Back-end >  Methods signature got changed while compiling the gradle java application and referencing to other p
Methods signature got changed while compiling the gradle java application and referencing to other p

Time:05-27

I have two projects known as (Common and ApiGateway).The common is a Gradle java project and ApiGateway is a Micronaut java application. In the common project, I am keeping all the common things and referencing the jar to the Apigateway project.

Common project

The below code is compiled with ./gradlew build

@Validated
public interface IProductOperation {
    @Get(value = "/search/{text}")
    @Secured(SecurityRule.IS_ANONYMOUS)
    Flux<?> freeTextSearch(@NotBlank String text);


    @Get(value = "/{?searchCriteria*}")
    @Secured(SecurityRule.IS_ANONYMOUS)
    Mono<?> find(FilterProductModel searchCriteria);
}

The API gateway implements the IProductOperation interface which is in the common project. When I navigate to the code base, I can see the below code is generated

@Validated
public interface IProductOperation {

    @Get("/search/{text}")
    @Secured({"isAnonymous()"})
    Flux<?> freeTextSearch(@NotBlank String var1);


    @Get("/{?searchCriteria*}")
    @Secured({"isAnonymous()"})
    Mono<?> find(FilterProductModel var1);

}

Now when I compile the second application the Apigateway project, I get an exception as The route declares a uri variable named [text], but no corresponding method argument is present which is valid because the parameter in freeTextSearch() and find() methods got changed to var1.

I have below dependency in the common project

dependencies {
    annotationProcessor "io.micronaut:micronaut-inject-java:3.5.0"
    annotationProcessor "io.micronaut:micronaut-validation:3.5.0"

    implementation('io.swagger.core.v3:swagger-annotations:2.2.0')
    implementation 'io.micronaut:micronaut-core:3.5.0'

    implementation "io.micronaut:micronaut-inject:3.5.0"
    implementation 'io.micronaut:micronaut-validation:3.5.0'
    implementation ('io.micronaut.reactor:micronaut-reactor:2.2.2')
    implementation("io.micronaut.security:micronaut-security-jwt:3.6.0")
}

I have build the application and publish to local mavel.

CodePudding user response:

The documentation has a section about retaining parameter names https://docs.micronaut.io/latest/guide/#retainparameternames

  • Related