title: Can CDI dependency injection be optional?
body: <p>In Spring DI, declaring an autowired field as Optional enables a client to not inject any value to it. Is this possible using Java EE's CDI? I tried Optional and it fails. I want to know if there is an equivalent mechanism I can use.</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>public class OmeletteMaker implements EggMaker{
          public static void main(String[] args){
          WeldContainer container = new Weld().initialize();
          OmeletteMaker omeletteMaker = container.instance().select(OmeletteMaker.class).get();
      }
  
      @Inject
      Optional&lt;Vegetable&gt; vegetable;
  }
  </code></pre>
  
  <p>I get an error message:
  Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Optional] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject cafeteria.OmeletteMaker.vegetable]</p>