Hi,

I'd like to use a producer method in ALL CASES when @Injecting a particular bean.

It looks like this:

public class FooProducer {

    @Produces
    public Foo produceFoo() {
        Foo foo = new Foo();
        return foo;
    }
}

public class Foo {}

With this example I get:

SEVERE - CDI Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: Ambiguous resolution
found beans:
Foo, Name:null, WebBeans Type:MANAGED, API Types:[....Foo,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default] Foo, Name:null, WebBeans Type:PRODUCERMETHOD, API Types:[....Foo,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]

I tried applying @Default with no success.

And I don't want to make specific @Qualifier annotation, because this is unnecessary in my case and will cause errors in those cases when I forget to provide that @Qualifier at injection point.

If anyone could help me with setting up a correct way to provide default producer, would be great.

thanks and kind regards
Reinis

Reply via email to