首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Quarkus get started”︁的源代码
←
Quarkus get started
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
= Why Quarkus= Quarkus is defined as a “Kubernetes Native Java stack tailored for OpenJDK HotSpot and GraalVM, crafted from the best of breed Java libraries and standards” == A Kubernetes native stack == Targeting Kubernetes as the target deployment platform, designed for containers as the main packaging format utilized in the cloud and by providing a toolset that allows you to build and deploy containers in a single step. Additionally, Quarkus supports a series of features that promote integration with the cloud platforms (e.g., exposing health-related information, external configuration options, etc.), which are integral to a positive user experience in the cloud environment == OpenJDK HotSpot and GraalVM == GraalVM compiler and the native image compilation, which are the main parts of GraalVM that Quarkus utilizes. Native compilation allows users to build a standalone binary executable that runs without requiring a JVM. == libraries and standards== Quarkus uses standards like MicroProfile (https://microprofile.io) and Jakarta EE (Enterprise Edition; https://jakarta.ee) and popular open source frameworks such as Hibernate (https://hibernate.org), Vertx (https://vertx.io), Apache Camel (https:// camel.apache.org), or RESTEasy (https://resteasy.dev). This allows developers to reuse their expertise and years of practice with these libraries when they start working with Quarkus = Get started = == Install CLI== <syntaxhighlight lang="bash"> curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/ curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio </syntaxhighlight> == Hello world == <syntaxhighlight lang="cpp"> quarkus create && cd code-with-quarkus </syntaxhighlight> <syntaxhighlight lang="cpp"> $ quarkus dev ... [INFO] Compiling 2 source files with javac [debug parameters release 21] to target/test-classes Listening for transport dt_socket at address: 5005 __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2025-08-14 00:14:31,380 INFO [io.quarkus] (Quarkus Main Thread) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.25.2) started in 2.921s. Listening on: http://localhost:8080 2025-08-14 00:14:31,386 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2025-08-14 00:14:31,387 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, rest, smallrye-context-propagation, vertx] -- Tests paused Press [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle test output, [:] for the terminal, [h] for more options> </syntaxhighlight> = Development = == Build & Run == <syntaxhighlight lang="cpp"> $ quarkus dev # or $ ./mvnw compile quarkus:dev </syntaxhighlight> Access DEV UI: http://localhost:8080/q/dev-ui/ [[Image:quarkus-devui.png|600px]] == Build native == <ref>https://quarkus.io/guides/building-native-image</ref> <syntaxhighlight lang="cpp"> echo $GRAALVM_HOME /Library/Java/JavaVirtualMachines/graalvm-jdk-24.0.2+11.1/Contents/Home $ quarkus build --native ... Finished generating 'customer-service-1.0.0-SNAPSHOT-runner' in 3m 20s. </syntaxhighlight> <syntaxhighlight lang="cpp"> ./build/customer-service-1.0.0-SNAPSHOT-runner __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2025-08-14 23:26:11,299 INFO [io.quarkus] (main) customer-service 1.0.0-SNAPSHOT native (powered by Quarkus 3.25.3) started in 0.028s. Listening on: http://0.0.0.0:8080 2025-08-14 23:26:11,299 INFO [io.quarkus] (main) Profile prod activated. 2025-08-14 23:26:11,299 INFO [io.quarkus] (main) Installed features: [cdi, rest, smallrye-context-propagation, vertx] </syntaxhighlight> == Test native image== <ref>https://quarkus.io/guides/getting-started-testing#quarkus-integration-test</ref> <syntaxhighlight lang="cpp"> $ ./mvnw verify -Dnative # By default, Quarkus waits for 60 seconds for the native image to start before automatically failing the native tests. # ./mvnw verify -Dnative -Dquarkus.test.wait-time=300. ... [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.967 s -- in com.riguz.ystack.GreetingResourceIT [INFO] [INFO] Results: [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] --- quarkus:3.25.3:native-image-agent (default) @ customer-service --- [INFO] [INFO] --- failsafe:3.5.3:verify (default) @ customer-service --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:15 min [INFO] Finished at: 2025-08-15T00:02:55+08:00 [INFO] ------------------------------------------------------------------------ </syntaxhighlight> [[Category:Quarkus]]
返回
Quarkus get started
。