It’s been a long day, with me starting to learn Micronaut, with reactive MongoDB (reactor).

I came across a strange situation where I would call a @Get endpoint, which had a variable of @PathVariable ObjectId, but got a bad request (from Postman).

I found another project (, which allowed me to pass the @PathVariable successfully (to MongoDB). The only issue was this was using Gradle, and i’m using Maven.

I found a useful stackoverflow post, which described using the Maven-Publish plugin to convert build.gradle to pom.xml:


Since Gradle 7, Maven-Publish tasks are automatically added to your Gradle tasks (

Micronaut uses sdkman ( for it’s tooling.

I managed to convert build.gradle to pom.xml, by following these steps:

(i). I installed gradle 7.4.2, by running:

sdk list gradle
sdk install gradle 7.4.2

Available Gradle Versions
     7.5-rc-1            6.2.2               4.7                 2.8
 > * 7.4.2               6.2.1               4.6                 2.7

(ii). I then added the following to my build.gradle:

Add maven-publish to my plugins:

plugins {
    id 'maven-publish'

Add the following publishing configuration:

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'edu.bbte.gradleex.mavenplugin'
            artifactId = 'gradleex-mavenplugin'
            version = '1.0.0-SNAPSHOT'


(iii). Run the generatePomFileForMavenPublication task:

When you look the Gradle tasks, you will see (under publishing), a generatePomFileForMavenPublication:

Gradle Publish task

$ gradle generatePomFileForMavenPublication

1 actionable task: 1 executed

A file named ./build/publications/maven/pom-default.xml will have been generated.

(iv). I copied this file to my project root, renaming to pom.xml.

Closed the project, and created new project (using Idea), and was able to confirm that the controller @Get was now working as expected.

marvellous :)