Quarkus 后端开发记录
最近业余在开发一款智能助理产品,记录开发过程中的一些问题以备忘,也是帮其他人防坑。
主要技术栈
- Quarkus: the Supersonic Subatomic Java Framework.
- RESTEasy Reactive: 实现 RESTful 接口 (JAX-RS)
- Hibernate Reactive: 是 Hibernate ORM 的响应式 API,支持非阻塞数据库驱动程序和响应式与数据库的交互方式。
- Panache: 简化基于 Jakarta REST、Hibernate ORM 的 CRUD 操作
- Neo4j: 图数据库
- Postgresql: 关系型数据库
- GraphQL: 接口
- JWT: 认证
- websocket: 实时通信
- JDK 17
- Apache Maven
前端 Nextjs 技术栈
开发
启动开发模式,支持代码热加载:
./mvnw compile quarkus:dev
提示: Quarkus 开发模式下提供了一个 Dev UI:http://localhost:8080/q/dev-ui/ .
接口
Openapi swagger-ui
http://localhost:8080/q/swagger-ui
打包
./mvnw package
打包完成在 target/quarkus-app/
目录下生成 quarkus-run.jar
文件.
注意默认不是 über-jar 模式, 相关依赖会生成到 target/quarkus-app/lib/
目录下.
运行
java -jar target/quarkus-app/quarkus-run.jar
.
über-jar 打包模式:
./mvnw package -Dquarkus.package.type=uber-jar
# 运行
java -jar target/*-runner.jar
创建本地可执行程序
./mvnw package -Pnative
Or, if you don’t have GraalVM installed, you can run the native executable build in a container using:
./mvnw package -Pnative -Dquarkus.native.container-build=true
运行程序: ./target/xueji-server-1.0.0-SNAPSHOT-runner
更多关于创建本地应用参考: https://quarkus.io/guides/maven-tooling.
注意
- 端口按照应用核心的需要来设计而不是简单地套用工具的 API。 it is of utmost importance that the Ports are created to fit the Application Core needs and not simply mimic the tools APIs.
- 配置阿里格式 Idea 插件: https://github.com/alibaba/p3c/blob/master/idea-plugin/README_cn.md
升级 Quarkus
Chocolatey is a package manager for Windows.
# 安装
choco install quarkus
# 升级 quarkus cli
choco upgrade quarkus
# 升级 quarkus 版本
quarkus update
指南
- Explicit Architecture (guide): 架构设计,DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together
- RESTEasy Reactive (guide): A Jakarta REST implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
- Mutiny(guide): Intuitive Event-Driven Reactive Programming Library for Java
- Quarkus Neo4j (guide): Quarkus-Neo4j extension, based on the official Neo4j Java Driver.
- Hibernate Reactive Panache (guide): Making your entities trivial and fun to write in Quarkus.
- Reactive PostgreSQL client (guide): Connect to the PostgreSQL database using the reactive pattern
- REST Client Reactive (guide): Interact with REST APIs
- WebSockets (guide): WebSocket communication channel support
- SmallRye JWT (guide): Secure your applications with JSON Web Token
- SmallRye JWT Build (guide): Create JSON Web Token with SmallRye JWT Build API
- SmallRye GraphQL (guide): Create GraphQL Endpoints using the code-first approach from MicroProfile GraphQL
- Transaction Manager (guide): Quarkus comes with a Transaction Manager and uses it to coordinate and expose transactions to your applications
- Scheduler (guide): Schedule jobs and tasks
欢迎合作
如果这篇文章对您有所帮助,欢迎点赞、分享和留言,让更多的人受益。感谢您的细心阅读,如果发现了任何错误或需要补充的地方,请随时告诉我,我会尽快处理
^_^