Quarkus - Guides
上下文依赖注入
Quarkus DI 方案基于 Java 上下文依赖注入 v2.0 标准。但是它不是一个符合 TCK 的完整 CDI 实现。 只实现了 CDI 一部分功能 —— 可以查看支持及限制列表。
Web
Hibernate Validator 进行验证
This guide covers how to use Hibernate Validator/Bean Validation in your REST services.
调用 REST 接口(包括 JSON)
This guide explains how to use the MicroProfile REST Client in order to interact with REST APIs (JSON and other) with very little effort.
发送文件给 REST 接口
This guide explains how to use the MicroProfile REST Client to send multipart REST requests, typically to upload documents.
Using JWT RBAC
This guide explains how your application can utilize MicroProfile JWT RBAC to provide secured access to the JAX-RS endpoints.
使用 WebSockets
This guide explains how your Quarkus application can utilize web sockets to create interactive web applications. Because it’s the canonical web socket application, we are going to create a simple chat application.
使用 OpenAPI 和 Swagger UI
This guide explains how to use the OpenAPI extension to generate an OpenAPI descriptor and get a Swagger UI frontend to test your REST endpoints.
HTTP 参考
Learn more about configuring Quarkus’ Vert.x based HTTP layer - and Undertow if you are using servlets.
使用熔断
This guide demonstrates how your Quarkus application can utilize the MicroProfile Fault Tolerance specification through the SmallRye Fault Tolerance extension.
数据
使用 Hibernate ORM 和 JPA
Hibernate ORM is the de facto JPA implementation and offers you the full breath of an Object Relational Mapper. It works beautifully in Quarkus.
用 Panache 简便 Hibernate ORM
Hibernate ORM is the de facto JPA implementation and offers you the full breadth of an Object Relational Mapper.
It makes complex mappings possible, but it does not make simple and common mappings trivial.
Panache focuses on making your entities trivial and fun to write.
Hibernate Search + Elasticsearch
Hibernate Search allows you to index your entities in an Elasticsearch cluster and easily offer full text search in all your Hibernate ORM-based applications.
使用事务
Quarkus comes with a Transaction Manager and uses it to coordinate and expose transactions to your applications. Each extension dealing with persistence will integrate with it for you. And you will explicitly interact with transactions via CDI. This guide will walk you through all that.
用 Hibernate Validator 验证
This guide covers how to use Hibernate Validator/Bean Validation in your REST services.
缓存应用数据
This guide explains how to cache expensive method calls of your CDI beans using simple annotations.
用 Flyway 迁移表结构
This guide covers how to use the Flyway extension to manage your schema migrations.
用 Liquibase 迁移表结构
This guide covers how to use the Liquibase extension to manage your schema migrations.
用 Infinispan 客户端
Infinispan is an in memory data grid that allows running in a server outside of application processes. This extension provides functionality to allow the client that can connect to said server when running in Quarkus.
响应式 SQL 客户端
This guide covers how to use the Reactive SQL Clients for MySQL and PostgreSQL in Quarkus.
Panache 使用 MongoDB
This guide covers the usage of MongoDB using active records and repositories.
消息
使用 Apache Kafka
This guide demonstrates how your Quarkus application can utilize MicroProfile Reactive Messaging to interact with Apache Kafka.
AMQP 的响应式消息
This guide demonstrates how your Quarkus application can utilize MicroProfile Reactive Messaging to interact with AMQP.
使用 Apache Kafka 流
This guide demonstrates how your Quarkus application can utilize the Apache Kafka Streams API to implement stream processing applications based on Apache Kafka.
使用 JMS
This guide demonstrates how your Quarkus application can use JMS messaging with AMQP 1.0 using Apache Qpid JMS, or using Apache ActiveMQ Artemis JMS.
安全
使用安全
This quide demonstrates integration with the Elytron security subsystem to allow for RBAC based on the common security annotations @RolesAllowed
, @DenyAll
, @PermitAll
on REST endpoints.
用 .properties 文件实现安全
This guide demonstrates how your Quarkus application can use a .properties file to store your user identities.
用 JPA 实现安全
This guide demonstrates how your Quarkus application can use a database to store your user identities with Hibernate ORM.
用 JDBC 实现安全
This guide demonstrates how your Quarkus application can use a database to store your user identities.
用 OpenID 连接来保护服务程序
This guide demonstrates how your Quarkus application can use Keycloak to protect your JAX-RS applications using bearer token authorization, where these tokens are issued by a Keycloak server.
用 OpenID 连接来保护 Web 应用
This guide demonstrates how to use the OpenID Connect Extension to protect your web application based on the Authorization Code Flow using Quarkus.
Using OpenID Connect Multi-Tenancy
This guide demonstrates how your OpenID Connect application can support multi-tenancy so that you can serve multiple tenants from a single application.
使用 OpenID Connect 和 Keycloak 实现中心化授权
This guide demonstrates how your Quarkus application can authorize access to protected resources using Keycloak Authorization Services.
使用 JWT RBAC
This guide explains how your application can utilize MicroProfile JWT RBAC to provide secured access to the JAX-RS endpoints.
使用 OAuth2 RBAC
This guide explains how your Quarkus application can utilize OAuth2 tokens to provide secured access to the JAX-RS endpoints.
使用 Vault
This quide explains how you can use HashiCorp Vault to securely store your credentials in Quarkus.
使用 Vault Transit Secret Engine
This quide explains how you can use HashiCorp Vault for “encryption as a service”.
Business Automation
Using Kogito to add business automation capabilities to an application
This guide demonstrates how your Quarkus application can use Kogito to add business automation to power it up with business processes and rules.
Using AI to optimize a schedule with OptaPlanner
This guide walks you through the process of creating a Quarkus application with OptaPlanner’s constraint solving Artificial Intelligence (AI).
集成
云
构建容器镜像
Learn how to build and push container images with Jib, S2I or Docker as part of the Quarkus build.
用 S2I 发布到 OpenShift
This guide explains how to deploy a Quarkus application to OpenShift using S2I.
发布原生应用到 Knative Kubernetes 或 OpenShift
This guide demonstrates how to deploy an application on Knative Kubernetes or OpenShift.
Using the Kubernetes Client to Interact with a Kubernetes Cluster
This guide demonstrates how to use the Fabric8 Kubernetes client to interact with your Kubernetes cluster.
Deploying to Microsoft Azure Cloud
This guide explains how to deploy a Quarkus application to Microsoft Azure Cloud.
Azure Functions (Serverless) with Vert.x Web, Servlet, or RESTEasy
This guide explains how you can deploy Vert.x Web, Servlet, or RESTEasy microservices as an Azure Function.
Amazon Lambda with Vert.x Web, Servlet, or RESTEasy
This guide explains how you can deploy Vert.x Web, Servlet, or RESTEasy microservices as an Amazon Lambda.
监测
使用健康检查
This guide demonstrates how your Quarkus application can utilize the MicroProfile Health specification through the SmallRye Health extension.
使用 OpenTracing
This guide explains how your Quarkus application can utilize OpenTracing to provide distributed tracing for interactive web applications.
采集指标
This guide demonstrates how your Quarkus application can utilize the MicroProfile Metrics specification through the SmallRye Metrics extension.
使用熔断器
This guide demonstrates how your Quarkus application can utilize the MicroProfile Fault Tolerance specification through the SmallRye Fault Tolerance extension.
用 Sentry 监控日志
This guide explains how to use Sentry to monitor your application and be notified when exceptions occur.
日志集中管理
This guide explains how to centralize your logs with Logstash or Fluentd using the Graylog Extended Log Format (GELF).
序列化
Writing REST JSON Services
JSON is now the lingua franca between microservices. In this guide, we see how you can get your REST services to consume and produce JSON payloads.
工具
用 Maven 构建应用
This guide covers:
- Maven configuration
- Creating a new project
- Dealing with extensions
- Development mode
- Debugging
- Import in your IDE
- Building a native image
- Build a container friendly executable
用 Gradle 构建应用
This guide covers:
- Gradle configuration
- Creating a new project
- Dealing with extensions
- Development mode
- Debugging
- Import in your IDE
- Building a native image
- Build a container friendly executable
Measuring the coverage of your tests
This guide explains how to measure the test coverage of your Quarkus application.
兼容
Using the Quarkus Extension for Spring DI API
While you are encouraged to use CDI annotations for injection, Quarkus provides a compatibility layer for Spring dependency injection in the form of the spring-di extension.
Using the Quarkus Extension for Spring Web API
While you are encouraged to use JAX-RS annotations for defining REST endpoints, Quarkus provides a compatibility layer for Spring Web in the form of the spring-web extension.
Using the Quarkus Extension for Spring Data JPA API
While you are encouraged to use Hibernate ORM with Panache for your data layer, Quarkus provides a compatibility layer for Spring Data JPA in the form of the spring-data-jpa extension.
Using the Quarkus Extension for Spring Security API
While you are encouraged to use the Quarkus security layer to secure your applications, Quarkus provides a compatibility layer for Spring Security in the form of the spring-security extension.
Using the Quarkus Extension for Spring Cloud Config
Quarkus provides a compatibility layer for Spring Cloud Config in the form of the spring-cloud-config-client extension.
Writing Extensions
Writing Your Own Extension
Quarkus extensions add a new developer focused behavior to the core offering, and consist of two distinct parts, buildtime augmentation and runtime container. The augmentation part is responsible for all metadata processing, such as reading annotations, XML descriptors etc. The output of this augmentation phase is recorded bytecode which is responsible for directly instantiating the relevant runtime services.
This means that metadata is only processed once at build time, which both saves on startup time, and also on memory usage as the classes etc that are used for processing are not loaded (or even present) in the runtime JVM.
Writing Native Applications
This guide is a collection of tips to help you solve the problems you encounter when compiling applications to native executable.
Alternative Languages
其它
定时任务
Modern applications often need to run specific tasks periodically. In this guide, you learn how to schedule periodic tasks.
Scheduling Clustered Tasks with Quartz
You need clustering support for your scheduled tasks? This guide explains how to use the Quartz extension for that.
发送 Email
Learn more about how you can send email from a Quarkus application with our reactive email client.
用 Qute 模版
Learn more about how you can use templating in your applications with the Qute template engine.
用 Apache Tika 解析内容
Learn more about how you extract content from documents using the Apache Tika toolkit.
Access Git repositories with JGit
This guide explains how you can access Git repositories with JGit.
性能指标
When measuring the footprint of a Quarkus application, we measure Resident Set Size (RSS) and not the JVM heap size which is only a small part of the overall problem. The JVM not only allocates native memory for heap (-Xms
, -Xmx
) but also structures required by the jvm to run your application.