From the course: Java EE 8 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Qualifiers

Qualifiers - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

Qualifiers

- When multiple beans have the same type, we need to specify to CDI which bean should be injected at an injection point. To do this, we use qualifiers in CDI. CDI contains multiple built-in qualifiers that can be used, and we are able to build our own custom qualifiers when necessary. By default, every bean and injection point has the any and default annotations that are used as qualifiers when there are no qualifiers explicitly declared. It's just assumed to be applied. You'll notice that within our application, we now another instance of the inventory service that will be created as a bean within our CDI container. Now this is going to create a problem. We can see that problem if we attempt to run our application. When CDI looks for a bean to inject into this injection point, it's going to have an error. That's because it doesn't know whether it should use our remote inventory service bean, or whether it…

Contents