SpringBoot PetClinic REST项目的GitHub存储库:https://github.com/spring-petclinic/spring-petclinic-rest
Quarkus迁移的项目的GitHub存储库:https://github.com/jonathanvila/spring-petclinic-rest/tree/quarkus
REST迁移
从Spring REST移到标准JAX-RS注释。
- @RestController --> @Path
- @RequestMapping --> 将其分解为下一个注释
- @GetMapping --> @GET
- @PostMapping --> @POST
- @PutMapping --> @PUT
- @DeleteMapping -> @DELETE
- @PathVariable -> @PathParam
安全迁移
将
- @PreAuthorize("hasRole(@roles.ROLE_ADMIN)") 替换为
- @RolesAllowed("ROLE_ADMIN")
添加Elytron扩展以在数据库中保持安全性:quarkus-elytron-security-JDBC扩展。在properties.file上配置这个新的扩展名
CORS
在application.properties文件中配置的CORS
指标
- 添加smallRye指标扩展
- 注释每种方法(用于自定义指标)
- 在属性文件中启用hibernate指标
验证方法迁移
- 将Spring验证器迁移到Hibernate验证器
- 从@ControllerAdvice移至JAX-RS ExceptionMapper
OpenAPI文件
- 添加扩展名“ openapi”
- 扩展应用程序类
本地缓存迁移
- Spring使用默认的ConcurrentHashMap
- Caffeine使用ConcurrentLinkedHashMap
- 添加“缓存”扩展名(Caffeine)并注释该方法
- 在属性文件中配置每个缓存行为
未迁移
- Spring JDBC查询
- 没有辅助方法可用于插入,更新
- 不等同于org.springframework.jdbc.core类
- 我们需要使用AGROAL重新实现所有功能
- JMX
迁移后性能比较:
Spring Boot Quarkus Hotspot Quarkus GraalVM
构建 48 MB 42 MB 97 MB
4.3 s 13 s 185 s
启动 630 MB 251 MB 21 MB
6.8 s 2.6 s 0.462 s
|