This is the 11th day of my participation in Gwen Challenge

A single spark can start a prairie fire.

In the nuggets to see a push activity: “Nuggets offline salon — embrace cloud native: explore the framework and storage under cloud native”, see one of the big man’s theme is “Java embrace cloud native — Quarkus introduction”, three years of work development said a face ignorant force, cloud native? Quarkus? Never heard of — learn!!

Quarkus introduction

Quarkus is said to be an open source microservices framework for RedHat, so can it be compared to SpringCloud/SpringBoot?

Not table, first look at the official documents! You can’t be the “some people” in your mouth ~ there should be a meme!

Quarkus website

What is Quarkus?

Quarkus is a full-stack, Kubernetes-native Java application framework designed for OpenJDK Hotspot and GraalVM. It is low memory consumption compared to Spring, fast startup, and allows for a combination of imperative code and non-blocking responsive style.

In What is Quarkus: Quarkus builds applications that consume 1/10 of the memory of traditional Java and start up faster (300 times faster).

Quarkus keyword

  1. Designed for developers: real-time coding, unified configuration, native executable file generation.

  2. Container first: Support for GraalVM/SubstrateVM, metadata processing at build time, reduced reflection use, native image preboot.

  3. Imperative and responsive code

Talk is Cheap, Show me the Code!

Quarkus of actual combat

Start Quarkus’ Hello World journey ~

The official tutorial

Environmental requirements:

  1. IDE: eclipse, idea, vscode, vim, emacs, etc. The environment we use is eclipse
  2. Java JDK 8 or 11+, I installed JDK 8
  3. Maven 3.6.2+ or Gradle. Maven 3.6.0 is installed on your computer

Git Clone github- Demo

git clone https://github.com/quarkusio/quarkus-quickstarts.git
#If you can't download the above link, try the following link:
# git clone [email protected]:quarkusio/quarkus-quickstarts.git  
Copy the code

Found that the project downloaded too much content

Instead of the official sample, we will follow the process of Bootstrapping the project:

Execute commands in Powershell:

MVN IO. Quarkus: quarkus -- maven plugin: 1.13.7. Final: create - DprojectGroupId = org. Acme - DprojectArtifactId = getting started -DclassName="org.acme.getting.started.GreetingResource" -Dpath="/hello"Copy the code

Output result:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:00 min [INFO] Finished at: 2021-06-11T18:00:18+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed To execute goal IO. Quarkus: quarkus -- maven plugin: 1.13.7. Final: the create (default - cli) on project standalone - pom: Detected Maven Version (3.6.0) is not supported, -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionExceptionCopy the code

Several errors were reported, suspecting that the problem was with our Maven version, so we updated Maven and re-ran the above command.

After upgrading Maven 3.8.0, run the following command:

applying codestarts...
>> java
>> maven
>> quarkus
>> config-properties
>> dockerfiles
>> maven-wrapper
>> resteasy-example

-----------
[SUCCESS] quarkus project has been successfully generated in: --> D:\XXXXX\learn\Quarkus\getting-started ----------- [INFO] [INFO] ======================================================================================== [INFO] Your new application has  been createdin D:\XXXXX\learn\Quarkus\getting-started
[INFO] Navigate into this directory and launch your application with mvn quarkus:dev
[INFO] Your application will be accessible on http://localhost:8080
[INFO] ========================================================================================
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:36 min
[INFO] Finished at: 2021-06-11T20:31:23+08:00
[INFO] ------------------------------------------------------------------------
Copy the code

As you can see, there is a “greeting-Started” Maven project that we imported into Eclipse. The project directory looks like this:

Let’s try running the project:

cd .\getting-started\
./mvnw compile quarkus:dev
Copy the code

Output from Powershell:

[INFO] Scanning for projects... Downloading from central: https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.13.7.Final/quarkus-universe-bom-1.13.7.Final.pom Downloaded from central: https://repo.maven.apache.org/maven2/io/quarkus/quarkus-universe-bom/1.13.7.Final/quarkus-universe-bom-1.13.7.Final.pom (614 kB at 256 kB/s) [INFO] [INFO] ----------------------< org.acme:getting-started >---------------------- [INFO] Building getting started - 1.0.0 - the SNAPSHOT [INFO] -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- (jar) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Downloading from central: https://repo.maven.apache.org/maven2/io/quarkus/quarkus-arc/1.13.7.Final/quarkus-arc-1.13.7.Final.pom... Omitted [INFO] -- Maven-resources-plugin :2.6:resources (default-resources) @get-started -- [INFO] Using 'utf-8' Encoding to copy filtered resources. [INFO] Copy2 resources [INFO] [INFO] -- Maven-Compiler-plugin :3.8.1:compile (default-compile) @ getting-started --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:\QiWeiwei\learn\Quarkus\getting-started\target\classes [INFO] [INFO] --- Final:dev (default-cli) @geting-started -- Listening for transport dt_socket at address: 5005 2021-06-11 20:50:51, 951 WARN [IO. Qua. Dep. QuarkusAugmentor] (main) Using Java versions older than 11 to build Quarkus applications is deprecated and will be disallowed in a future release! __ ____ ____ _____ _____ ____ _____ ______ - / __ / / / / / _ | / _ \ / / / _ / / / / __ / / / _ _ - / / / / / __ | /, _ /, / / __ / / \ \ - \ _ \ _ \ ____ _ / | _ / _ / | _ / _ / _ - | | \ _____ / ___ / 2021-06-11 20:50:54, 529 INFO/IO. Quarkus (quarkus Main Thread) getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.13.7.final) started in 2.757s. Listening on: http://localhost:8080 2021-06-11 20:50:54,530 INFO [IO. Quarkus] (quarkus Main Thread) Profile dev Activated. Live Coding Activated. 2021-06-11 20:50:54,531 INFO [IO. Quarkus] (Quarkus Main Thread) Installed features: [CDI, resteasy]Copy the code

The browser requests: http://localhost:8080/hello results are as follows