使用两个不同的ValidationFactory类

huangapple go评论74阅读模式
英文:

Using two different ValidationFactory classes

问题

我想在我的Quarkus应用程序中创建两个不同的ValidatorFactory类。这在JVM模式下运行正常,但在本地模式下,验证失败,出现Bean未找到的异常。

我知道Hibernate Validator在Quarkus中有很多封装,但在Quarkus本地构建中是否可以使用两个(或更多)ValidationFactory类,或者只能有一个?

更新:我们的用例是为了解决https://github.com/quarkusio/quarkus/issues/35007#issuecomment-1655908939的问题。目前还不可能,我们在等待更新。

更新2:2.16.9版本为我们解决了问题。

英文:

I would like to produce two different ValidatorFactory classes in my quarkus application. This works fine in jvm mode, but in native mode, the validation fails with Bean not found exceptions.

I know the hibernate validator is heavily wrapped by quarkus, but is it possible to use two (or more) ValidationFactory classes in quarkus native build or can there be only one?

Update: our usecase was to workaround https://github.com/quarkusio/quarkus/issues/35007#issuecomment-1655908939 It is not possible for the moment, we wait for the update.

Update 2: 2.16.9 solved the issues for us.

答案1

得分: 1

创建自己的 ValidatorFactory 在 Quarkus 中不受支持,主要是由于本地编译的原因,还因为它允许我们非常谨慎地配置和优化事务。

在 JVM 中,正如您所指出的,它在某种程度上可以工作,因为您可以在 JVM 中创建 ValidatorFactory,但在本地编译中,它根本不起作用,因为本地二进制文件的构建方式以及反射使用的限制。

您能告诉我更多关于您的用例吗?以及您设想它如何工作?我想您可能希望为这两个 ValidatorFactory 使用不同的配置?

现在,我不太清楚我最初在 Quarkus 中开发 Hibernate Validator 支持时遇到的所有限制,而自 Quarkus 开始以来,GraalVM 取得了巨大的进展。

也许可以在 Quarkus 跟踪器中创建一个问题,附带一个小的 Maven 示例,展示您想要做什么,我会在接下来的几天里尝试查看一下。

英文:

Creating your own ValidatorFactory is not supported in Quarkus, mostly due to native, but also because it allowed us to configure things very carefully and optimize things.

In JVM, as you noted, it will somehow work as you can create a ValidatorFactory in JVM, but in native, it won't work at all due to how native binaries are built and because of the restrictions on reflection usage.

Could you tell me more about your use case? And how you envisioned it to work? I suppose you wanted two different configurations for the two ValidatorFactory?

Now, I don't recall exactly all the restrictions I hit when I initially developed the Hibernate Validator support in Quarkus and GraalVM has made enormous progress since the beginning of Quarkus.

Maybe create an issue in the Quarkus tracker with a small Maven reproducer showing what you're trying to do and I'll try to have a look in the next few days.

huangapple
  • 本文由 发表于 2023年7月28日 05:36:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76783533.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定