2.5 KiB
Micronaut course
[toc]
Learning sessions log
Session 1 : 04/11/2022
Daniel - Instructor for the course
Living in Austria - working at technical lead with backend applications. Deploying to aws.
Goal for this course: following it for 45min/day.
Session 2 : 06/11/2022 - continue with micronaut quickstart, create a hello world endpoint and test it with @MicronautTest
Unit 1 : Introduction
Spring / Micronaut / Quarkus (09/2020)
Spring - dominating the Java world
- well established
- reactive stack with Spring WebFlux (since v5)
- biggest community
- most integrations
- multi language support
- heavy use of reflection
- support for GraalVM (beta)
Quarkus - cloud native framework
- reactive stack
- minimal memory footprint at startup time
- based on standards and frameworks
- GraalVM / serverless cloud functions
- slower compilation time (AOT)
- smaller community as Spring
Micronaut - modern cloud native framework
- reactive stack
- minimal footprint and startup time
- no byte code modidications during compilation
- removes all leves of reflection usage
- GraalVM / serverless cloud functions
- multi language support (Java, Groovy, Kotlin)
- quite similar to Spring framework (good if you have spring background)
- slower compilation time (AOT)
- smaller community as Spring
Code examples and setup
Course is compatible with version 3.1
Unit 2: Micronaut 3 - quickstart
Cf. https://micronaut.io and https://micronaut.io/launch
Create a first project with:
- Micronaut 3 LTS
- Java 11
- Maven
- Junit
Dependancies: Netty server
Creating our first endpoint
Create a hello world endpoint using annotations.
- create a java class
- add
@Controller("/path")
annotation at class level - add
@Get(produces = MediaType.TEXT_PLAIN)
at method level
NOTE: access http://localhost:8080/hello to see plain text hello world displayed.
First micronaut test experience
Let's automate - making sure that written code works
- create a test class in test folder
- add annotation
@MicronautTest
at class level - add a class with
@Test
annotation - create a HttpClient using
@Inject
&@Client("/")
- use the
HttpClient client
as a blocking client (for simplicity now) and query the/hello
endpoint
NOTE: by default a @MicronautTest
is a functionnal test. So to create a unit test simply remove the annotation and use your prefered test framework.
Session 3 will start here