title: How to declare an optional @Bean in Spring?
body: <p>I want to provide an optional <code>@Bean</code> in my <code>@Configuration</code> file like:</p>
  
  <pre><code>@Bean
  public Type method(Type dependency) {
      // TODO
  }
  </code></pre>
  
  <p>when dependency can't be found, the method should not be called. </p>
  
  <p>How to do that?</p>