Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 437 Bytes

08-constructeur-bean.md

File metadata and controls

24 lines (17 loc) · 437 Bytes

Constructeur de bean

  • @Bean définit un bean.

  • L'identifiant du bean est déterminé par le nom de la méthode.

  • L'injection est effectuée dans le corps de la méthode.

@Configuration
public class AppConfig {
    
    @Bean
    public PizzaService pizzaService() { 
        return new PizzaService();
    }
    
    @Bean
    public PizzaRepository pizzaRepo() { 
        return new PizzaRepository();
    }
}