Skip to content
Tutorials Center
My learning

Topics

Micronaut Tutorial

Learn Micronaut step by step: 38 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Micronaut? Meet Micronaut, the JVM framework that does dependency injection at compile time: fast startup, low memory, small native images, and where it fits.
  2. 2 Creating a Micronaut App Create a Micronaut project with the mn CLI or Micronaut Launch, pick the language, build tool and features, and understand what the generator writes.
  3. 3 Project Structure and Configuration Tour a Micronaut project: the Application class, application.yml, environments, property placeholders and the order in which configuration sources win.
  4. 4 Your First Controller Write your first Micronaut endpoint with @Controller and @Get, run it with Gradle or Maven, call it with curl, and see how requests are routed to methods.
  5. 5 Ahead-of-Time Compilation How Micronaut's annotation processors generate bean definitions, introspection and AOP advice during the build, so no reflection or runtime proxies are needed.

Beans and Dependency Injection

  1. 6 Beans and Singletons Define Micronaut beans with @Singleton, inject them through constructors, fields and methods, choose between implementations, and avoid circular dependencies.
  2. 7 Qualifiers and Factories Choose between several beans of the same type with @Named, @Primary and custom qualifiers, and create beans from third-party classes with @Factory and @Bean.
  3. 8 Scopes, Lifecycle and Events Understand Micronaut scopes (@Singleton, @Prototype, @Context, @Refreshable), @PostConstruct and @PreDestroy hooks, and the application event system.
  4. 9 Conditional Beans Enable beans only when a property, environment, class or other bean is present with @Requires, and swap implementations with @Replaces and @Secondary.
  5. 10 AOP and Method Interceptors Add logging, caching, retries and timing to Micronaut beans without touching their code, using @Around advice and MethodInterceptor. Includes runnable stand-ins.

HTTP Server and Clients

  1. 11 Controllers and Routing Map HTTP verbs and URIs to Micronaut controller methods: @Get, @Post, @Put, @Delete, path variables, query values, headers and route precedence.
  2. 12 Request Binding and Responses Read request bodies, forms and uploads in Micronaut, and build responses with HttpResponse, status codes, headers and content negotiation.
  3. 13 JSON and Serialization How Micronaut turns objects into JSON and back: Micronaut Serialization with @Serdeable, records, Jackson annotations, naming, dates, nulls and third-party types.
  4. 14 Declarative HTTP Clients Call other services in Micronaut by writing an interface with @Client and @Get. Learn URI templates, error handling, and see the idea in a runnable Java stand-in.
  5. 15 Filters and Error Handling Run code around every request with Micronaut HTTP filters, and turn exceptions into clean JSON errors with @Error and ExceptionHandler. Runnable Java stand-ins included.
  6. 16 Streaming, Server-Sent Events and Async Handle slow work and live data in Micronaut: reactive return types, server-sent events, streaming responses and @ExecuteOn. With runnable Java stand-ins.

Data Access

  1. 17 Data Sources and Connection Pools Connect a Micronaut app to a database: datasource configuration, HikariCP pool sizing, environments and H2. Runnable JDBC and connection-pool stand-ins on Java.
  2. 18 Micronaut Data and Repositories Learn Micronaut Data: entities, CrudRepository interfaces, query methods derived from names, and how SQL is generated at compile time. Runnable H2 stand-ins.
  3. 19 Queries, Pagination and Projections Write explicit @Query methods, page results with Pageable and Page, and return slim DTO projections in Micronaut Data. Runnable H2 stand-ins show the SQL behind them.
  4. 20 Transactions and Database Migrations Keep data consistent with @Transactional in Micronaut and evolve your schema safely with Flyway migrations. Runnable H2 stand-ins show commit, rollback and a migrator.
  5. 21 Relationships and Other Data Stores Map one-to-many and many-to-many relations in Micronaut Data, avoid the N+1 query trap, and see where JPA, R2DBC and MongoDB fit. Runnable H2 stand-ins included.

Configuration and Validation

  1. 22 Configuration Files and Environments How Micronaut loads configuration: application.yml, environment variables, system properties, @Value, @Property and environment-specific files, with runnable Java stand-ins.
  2. 23 Typed Configuration with @ConfigurationProperties Bind groups of settings to typed Java classes with @ConfigurationProperties, @EachProperty and immutable records. Includes runnable binding stand-ins.
  3. 24 Bean Validation in Micronaut Validate request bodies, parameters and configuration with Jakarta Bean Validation in Micronaut: constraints, @Valid, @Validated, custom constraints and error responses.

Security

  1. 25 Security Fundamentals and Access Rules Secure a Micronaut app: the micronaut-security module, @Secured and SecurityRule, role checks, intercept-url-map, anonymous access and a runnable rule-engine stand-in.
  2. 26 Authentication Providers and Password Storage Write a Micronaut authentication provider, enable the login endpoint, store passwords with salted slow hashes and lock out brute-force attempts. Runnable Java stand-ins.
  3. 27 JWT Tokens in Micronaut How JSON Web Tokens work and how Micronaut Security issues and validates them: header, claims, HS256 signatures, expiry, refresh tokens and runnable Java stand-ins.
  4. 28 OAuth 2.0 and OpenID Connect Add login with Google, Keycloak or Okta to Micronaut using OAuth 2.0 and OpenID Connect: authorization code flow, PKCE, resource server setup and runnable flow stand-ins.

Cloud and Serverless

  1. 29 Service Discovery and Distributed Configuration Register Micronaut services, find them by name with @Client(id), load balance, use Consul and Kubernetes discovery, and share configuration. Runnable stand-ins.
  2. 30 AWS Lambda and Serverless Functions Build serverless functions with Micronaut: MicronautRequestHandler, API Gateway proxy controllers, cold starts, GraalVM native Lambdas and a runnable handler stand-in.
  3. 31 Metrics, Health Checks and Tracing Observe a Micronaut service in production: management endpoints, health indicators, Micrometer and Prometheus metrics, OpenTelemetry tracing and logging. Runnable stand-ins.

Testing and Native Images

  1. 32 Testing with Micronaut Test Write fast Micronaut tests with @MicronautTest, an embedded server, injected HTTP clients, @Property overrides and JUnit 5. Includes a runnable mini test harness stand-in.
  2. 33 Mocking, @MockBean and Test Resources Replace beans in tests with @MockBean and @Replaces, use Mockito or hand-written fakes, and start real databases with Micronaut Test Resources and Testcontainers.
  3. 34 GraalVM Native Image Basics Compile a Micronaut app to a native executable with GraalVM: what native image does, nativeCompile, Docker builds, startup and memory gains, trade-offs. Runnable stand-ins.
  4. 35 Native Image Pitfalls and Reflection Configuration Fix common GraalVM native image problems in Micronaut: reflection, resources, @ReflectiveAccess, @Introspected, serialization, build-time vs run-time init and debugging missing metadata.

Projects and Practice

  1. 36 Project: A Validated Notes REST API Build a complete Micronaut REST API: records, validation, a repository, a service, controllers, error handling and tests. With a runnable end-to-end Java stand-in.
  2. 37 Project: A Secured Inventory Service Build a JWT-secured inventory microservice in Micronaut with roles, stock rules, optimistic locking, health and metrics, plus a runnable end-to-end Java stand-in.
  3. 38 Project: Event-Driven Order Processing Design an order pipeline in Micronaut with application events, Kafka messaging, idempotent consumers, retries and a dead-letter queue, with a runnable Java event-bus stand-in.