且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Qualifier中应该使用Java EE7的@Nonbinding注释的目的是什么?

更新时间:2023-12-03 13:19:40


  1. 默认情况下,将限定符参数用于将Bean限定符与注入点限定符进行匹配。 @Nonbinding 参数不考虑匹配。

在这种情况下,由生产者方法具有限定符 @HttpParam()。如果参数具有约束力(即不是 @Nonbinding ),则 @HttpParam()将不匹配 @HttpParam(用户名)在注入点上。

In this case, the bean produced by the producer method has qualifier @HttpParam(""). If the argument were binding (i.e. not @Nonbinding), @HttpParam("") would not match @HttpParam("username") on the injection point.

您可以具有任意数量的限定符参数,这些参数是绑定的

You can have any number of qualifier arguments, binding or non-binding.

请参见类型安全分辨率