@Bean

From NovaOrdis Knowledge Base
Revision as of 01:35, 6 December 2018 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

Overview

@Bean in Spring Dependency Injection and Inversion of Control Container Concepts

Register a Bean under a Specific Name

The following registers a MyComponent singleton under the name "blue":

@Configuration
public class ... {

    @Bean("blue")
    public MyComponent getMyComponent() {
      return new MyComponent();
    }
}