Using the CLI you can create a new Micronaut application in either Groovy, Java or Kotlin (the default is Java).

    The following command creates a new “Hello World” server application in Java with a Gradle build:

    1. $ ./gradlew run
    2. > Task :run
    3. [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 972ms. Server Running: http://localhost:28933

    If you have created a Maven based project, use ./mvnw mn:run instead.

    By default the Micronaut HTTP server is configured to run on port 8080. See the section in the user guide for more options.

    1. import io.micronaut.http.MediaType
    2. @Controller('/hello') (1)
    3. class HelloController {
    4. @Get(produces = MediaType.TEXT_PLAIN) (2)
    5. 'Hello World' (3)
    6. }

    If you are using Java, place the previous file in src/main/java/hello/world.
    If you are using Groovy, place the previous file in src/main/groovy/hello/world.
    If you are using Kotlin, place the previous file in src/main/kotlin/hello/world.

    If you start the application and send a request to the /hello URI then the text “Hello World” is returned:

    1. $ curl http://localhost:8080/hello
    2. Hello World