quarkus - 我应该将@ConfigProperty 字段包装在 javax.enterprise.inject.Instance 对象中吗?
问题描述
在我的 quarkus 项目中,我在过滤器(ContainerRequestFilter、ContainerResponseFilter)中注入了几个 ConfigProperty。这在启动时给了我以下警告:
[io.qua.res.com.dep.ResteasyCommonProcessor] (build-46) Directly injecting a @ConfigProperty into a JAX-RS provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.lang.String>. Offending field is 'fieldName' of class 'className'
[io.qua.res.com.dep.ResteasyCommonProcessor] (build-46) Directly injecting a @ConfigProperty into a JAX-RS provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.util.List<java.lang.String>>. Offending field is 'fieldName' of class 'className'
但是,配置指南从未提及这一点,甚至显示了在 JAX-RS 资源中注入 ConfigProperty 的示例。
此外,尽管有警告,但一切正常。所以我的问题是:我应该关心这个警告并应用它的建议还是可以忽略它?为什么指南中没有提到这一点(无论是简短的,还是参考的)
我正在使用 quarkus 1.12.2,但我也遇到了以前版本的“问题”。
解决方案
该警告仅针对 JAX-RS 提供者显示,而不针对 JAX-RS 资源显示。
我建议您确实发出警告-但正如我上面提到的,仅对提供者进行更改(例如您提到的过滤器)
推荐阅读
- java - 房间数据库架构更新
- android - 有没有办法在 Android Zebra TC520K 上以编程方式扫描 ITF-14 条码?
- javascript - 如何使用ajax控制套件从当前日期选择三个日期之后的日期
- python - 通过 API 调用获取信息并进行身份验证
- qt - 在 centos 7 上从源代码编译 qt5.12 的 mysql 驱动程序
- sql - 如何在 Matillion Flow 的 SQL 组件中使用 SUBSTRING()?
- c# - ASP.Net:是否可以使用 Windows 身份验证并将 HttpContext.Current.User 设置为 GenericPrincipal
- linux - 为什么 Kubernetes 会为 ioctl 返回奇怪的结果
- bash - 期待 ping 测试的脚本
- r - 将 data.table 语法转换为 dplyr 语法