I am migrating an application to Java EE 7 and would like to CDI 1.1. But I don\'t get the meaning of bean-discovery-mode=\"annotated\". The
CDI 1.1 specificat
I also agree with the answer form @rmuller. But I want to point out that there is still different behavior on application servers Payara and Wildfly. See the following example with a normal not scoped class but having a @EJB injection:
public class SomeClass {
@EJB
MyService myService;
...
}
If you provide a beans.xml file with:
.... version="1.2" bean-discovery-mode="annotated"....
Payara 4.1 will treat the class SomeClass NOT as a CDI bean and will NOT inject the service EJB. This is clear to me that it behaves as stated in the specification.
But Wildfly 10 treats the class as an CDI bean and injects the service EJB which is not expected. To get this working the beans.xml file should look like this:
.... version="1.2" bean-discovery-mode="all"....
It's amazing that the two most common application servers are different here in behavior.