# helidon-quickstart-se **Repository Path**: framework-collection/helidon-quickstart-se ## Basic Information - **Project Name**: helidon-quickstart-se - **Description**: IDEA支持的框架helidon,Oracle开发的。这个框架既有声明式也有编程式写法。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: https://helidon.io/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-25 - **Last Updated**: 2022-11-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Helidon Quickstart SE Sample Helidon SE project that includes multiple REST operations. 支持声明式与编程式。 编程式,风格有点类似tornado的编程式写法。 声明式,类似SpringBoot的风格。 ## Quick Start https://helidon.io/docs/v2/#/se/guides/02_quickstart ## Create with maven3.8 ```shell mvn -U archetype:generate -DinteractiveMode=false \ -DarchetypeGroupId=io.helidon.archetypes \ -DarchetypeArtifactId=helidon-quickstart-se \ -DarchetypeVersion=2.4.1 \ -DgroupId=io.helidon.examples \ -DartifactId=helidon-quickstart-se \ -Dpackage=io.helidon.examples.quickstart.se ``` ## Build and run With JDK11+ ```bash mvn package java -jar target/helidon-quickstart-se.jar ``` ## Exercise the application ``` curl -X GET http://localhost:8080/greet {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe {"message":"Hello Joe!"} curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose {"message":"Hola Jose!"} ``` ## Try health and metrics ``` curl -s -X GET http://localhost:8080/health {"outcome":"UP",... . . . # Prometheus Format curl -s -X GET http://localhost:8080/metrics # TYPE base:gc_g1_young_generation_count gauge . . . # JSON Format curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics {"base":... . . . ``` ## Build the Docker Image ``` docker build -t helidon-quickstart-se . ``` ## Start the application with Docker ``` docker run --rm -p 8080:8080 helidon-quickstart-se:latest ``` Exercise the application as described above ## Deploy the application to Kubernetes ``` kubectl cluster-info # Verify which cluster kubectl get pods # Verify connectivity to cluster kubectl create -f app.yaml # Deploy application kubectl get pods # Wait for quickstart pod to be RUNNING kubectl get service helidon-quickstart-se # Get service info ``` Note the PORTs. You can now exercise the application as you did before but use the second port number (the NodePort) instead of 8080. After you’re done, cleanup. ``` kubectl delete -f app.yaml ``` ## Build a native image with GraalVM GraalVM allows you to compile your programs ahead-of-time into a native executable. See https://www.graalvm.org/docs/reference-manual/aot-compilation/ for more information. You can build a native executable in 2 different ways: * With a local installation of GraalVM * Using Docker ### Local build Download Graal VM at https://www.graalvm.org/downloads, the versions currently supported for Helidon are `20.1.0` and above. ``` # Setup the environment export GRAALVM_HOME=/path # build the native executable mvn package -Pnative-image ``` You can also put the Graal VM `bin` directory in your PATH, or pass `-DgraalVMHome=/path` to the Maven command. See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-native-image for more information. Start the application: ``` ./target/helidon-quickstart-se ``` ### Multi-stage Docker build Build the "native" Docker Image ``` docker build -t helidon-quickstart-se-native -f Dockerfile.native . ``` Start the application: ``` docker run --rm -p 8080:8080 helidon-quickstart-se-native:latest ``` ## Build a Java Runtime Image using jlink You can build a custom Java Runtime Image (JRI) containing the application jars and the JDK modules on which they depend. This image also: * Enables Class Data Sharing by default to reduce startup time. * Contains a customized `start` script to simplify CDS usage and support debug and test modes. You can build a custom JRI in two different ways: * Local * Using Docker ### Local build ``` # build the JRI mvn package -Pjlink-image ``` See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-jlink-image for more information. Start the application: ``` ./target/helidon-quickstart-se-jri/bin/start ``` ### Multi-stage Docker build Build the JRI as a Docker Image ``` docker build -t helidon-quickstart-se-jri -f Dockerfile.jlink . ``` Start the application: ``` docker run --rm -p 8080:8080 helidon-quickstart-se-jri:latest ``` See the start script help: ``` docker run --rm helidon-quickstart-se-jri:latest --help ```