Skip to content

Commit 02aa9d8

Browse files
cstancuban-mi
andcommitted
Integrate review comments.
Co-authored-by: Betty Mann <betty.mann@oracle.com>
1 parent b981132 commit 02aa9d8

File tree

1 file changed

+41
-12
lines changed
  • native-image/microservices/micronaut-hello-rest-maven-layered

1 file changed

+41
-12
lines changed

native-image/microservices/micronaut-hello-rest-maven-layered/README.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
1-
# Microanut Layered Native Image Demo
1+
# Micronaut Layered Native Image Demo
22

33
This example shows how to build a simple [Micronaut](https://micronaut.io/) REST application using the [GraalVM Native Image Layers](https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/imagelayer/NativeImageLayers.md) feature.
44

5+
### Prerequisites
6+
- SDKMAN! (for installing Micronaut CLI)
7+
- Latest GraalVM 25.1 EA build (with Native Image support)
8+
9+
> Native Image Layers is an experimental feature. For the best experience use the latest [GraalVM Early Access Build](https://github.com/graalvm/oracle-graalvm-ea-builds/releases).
10+
511
## Environment Setup
6-
Point your `JAVA_HOME` to a GraalVM distribution.
7-
Native Image Layers is an experimental feature, for best experience use the latest [GraalVM Early Access Build](https://github.com/graalvm/oracle-graalvm-ea-builds/releases).
12+
Point your `JAVA_HOME` to the GraalVM distribution.
813
```bash
914
export JAVA_HOME=/path/to/graalvm/ea/build
1015
```
1116

12-
## Create The Micronaut Application
13-
14-
We'll start by generating a basic application using the Micronaut CLI.
15-
For more details see the [Micronaut guide](https://guides.micronaut.io/latest/creating-your-first-micronaut-app-maven-java.html).
16-
17-
First we need to install the `mn` tool:
17+
Install `mn`, the Micronaut CLI tool:
1818
```bash
1919
sdk install micronaut 4.9.4
2020
sdk use micronaut 4.9.4
2121
```
2222

23-
Now we ca generate the basic app:
23+
## Create the Micronaut Application
24+
25+
We'll start by generating a basic application using the Micronaut CLI.
26+
For more details, see the [Micronaut guide](https://guides.micronaut.io/latest/creating-your-first-micronaut-app-maven-java.html).
27+
2428
```bash
2529
mn create-app example.micronaut.micronaut-hello-rest-maven-layered --build=maven --lang=java --features=graalvm
2630
```
2731

32+
This creates a new Micronaut project with the following structure:
33+
```
34+
micronaut-hello-rest-maven-layered/
35+
├── pom.xml
36+
├── src/
37+
│ ├── main/
38+
│ │ ├── java/
39+
│ │ │ └── example/micronaut/Application.java
40+
│ │ └── resources/
41+
│ │ └── application.properties
42+
│ └── test/
43+
└── mvnw (Maven wrapper)
44+
```
45+
46+
For executing the subsequent commnds we must enter the project directory:
47+
```bash
48+
cd micronaut-hello-rest-maven-layered
49+
```
50+
2851
### Add A Custom Controller
2952

3053
We'll add a custom controller to `src/main/java/example/micronaut/HelloController.java`:
@@ -74,7 +97,7 @@ Using this profile we can now generate the executable:
7497
./mvnw clean package -Dpackaging=native-image -Pstandalone
7598
```
7699

77-
This will generate an executable file that we can run
100+
This will generate an executable file that we can run:
78101
```bash
79102
./target/standalone-app
80103
__ __ _ _
@@ -84,9 +107,12 @@ This will generate an executable file that we can run
84107
|_| |_|_|\___|_| \___/|_| |_|\__,_|\__,_|\__|
85108
12:20:53.437 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 6ms. Server Running: http://localhost:8080
86109
```
87-
and test our custom endpoint
110+
and test our custom endpoint:
88111
```bash
89112
curl localhost:8080/hello
113+
```
114+
The expected output is:
115+
```
90116
Hello from GraalVM Native Image!
91117
```
92118
@@ -188,5 +214,8 @@ Then we can execute the layered application:
188214
and test it with:
189215
```
190216
curl localhost:8080/hello
217+
```
218+
The expected output is:
219+
```
191220
Hello from GraalVM Native Image!
192221
```

0 commit comments

Comments
 (0)