Annotation Type Bean


  • @Target(METHOD)
    @Retention(RUNTIME)
    public @interface Bean
    Marks methods on a @Factory bean that create dependencies.

    See Factory.

    
    
     @Factory
     class Configuration {
    
       private final StartConfig startConfig;
    
       @Inject
       Configuration(StartConfig startConfig) {
         this.startConfig = startConfig;
       }
    
       @Bean
       Foo buildFoo() {
         ...
         return new Foo(...);
       }
    
       @Bean
       Bar buildBar(Foo foo, Bazz bazz) {
         ...
         return new Bar(...);
       }
     }
     
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String destroyMethod
      Specify a method to be treated like a @PreDestroy
      String initMethod
      Specify a method to be treated like a @PostConstruct
    • Element Detail

      • initMethod

        String initMethod
        Specify a method to be treated like a @PostConstruct
        Default:
        ""