These tutorials target Micronaut Framework 3. Read, Guides for Micronaut Framework 4.

Application Class - Spring Boot to Micronaut Framework

This guide shows compares the Application Class of a Spring Boot application vs a Micronaut Framework application.

Authors: Sergio del Amo

Micronaut Version: 3.9.2

1. Sample Project

You can download a sample application with the code examples shown in this article.

2. Introduction

Spring Boot and Micronaut applications contain a simple application class which starts the application for you.

3. Spring Boot Application Class

springboot/src/main/groovy/example/micronaut/Application.groovy
package example.micronaut

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
class DemoApplication {

  static void main(String[] args) {
    SpringApplication.run(DemoApplication, args)
  }
}

3.1. Micronaut Framework Application Class

micronautframework/src/main/groovy/example/micronaut/Application.groovy
package example.micronaut

import io.micronaut.runtime.Micronaut
import groovy.transform.CompileStatic

@CompileStatic
class Application {

    static void main(String[] args) {
        Micronaut.run(Application, args)
    }
}

Except for the @SpringBootApplication annotation, both classes are almost identical. :-]

4. Next steps

Read more about Micronaut Spring.

5. Help with the Micronaut Framework

The Micronaut Foundation sponsored the creation of this Guide. A variety of consulting and support services are available.