我应该将 @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'

然而,configuration guide 从未提及这一点,甚至显示 an example 在 JAX-RS 资源中注入 ConfigProperty。

此外,尽管有警告,但一切正常。 所以我的问题是:我应该关心这个警告并应用它的建议还是我可以忽略它?为什么指南中没有提到这一点(既不是简短的,也不是 reference 的)

我使用的是 quarkus 1.12.2,但我之前的版本也有“问题”。

解决方法

警告仅针对 JAX-RS 提供程序显示,而不针对 JAX-RS 资源。

我建议您发出警告 - 但正如我上面提到的,只对提供者进行更改(如您提到的过滤器)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...