类似于Spring Boot中的@Primary的Quarkus注解

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

Annotation Like @Primary in Spring Boot for Quarkus

问题

在Quarkus中是否有类似于Spring Boot中的@Primary的等效注解?我发现了@DefaultBean,但它不起作用!!!

英文:

Is there any equivalent annotation like @Primary in Spring Boot for Quarkus?
I found @DefaultBean but it does not work!!!

答案1

得分: 1

Quarkus 使用 CDI 实现进行依赖注入。因此,您必须使用 @Default@Alternative 注解。请注意:在 CDI 中,@Default 总是在没有其他限定符的情况下设置在 bean 上,这就是为什么您必须在每个您不希望成为默认 bean 的 bean 上设置 @Alternative

英文:

Quarkus uses a CDI implementation for dependency injection. So, you have to use @Default and @Alternative annotations. Please note: In CDI, @Default is always set, behind the scenes, on beans which have no other qualifier. That’s why you have to set @Alternative on every bean which you do not want to be the default one!

答案2

得分: 0

use @javax.inject.Qualifier.
works fine.

英文:

use @javax.inject.Qualifier.
works fine.

huangapple
  • 本文由 发表于 2020年10月7日 18:55:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/64242600.html
匿名

发表评论

匿名网友

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

确定