Tutorial by Examples

The common case for injecting dependencies into a class is with constructor injection. This involves annotating a constructor on the class with @Inject. The CDI manager will look for a constructor with the @Inject annotation when creating an instance of the class. When it finds an @Inject-annotated ...
The same example from above can also be done using what is known as field injection. Instead of annotating the constructor with @Inject, we annotate the fields we wish to have injected public class Spaceship { @Inject private PropulsionSystem propulsionSystem; @Inject private ...

Page 1 of 1