- Kotlin Blueprints
- Ashish Belagali Hardik Trivedi Akshay Chordiya
- 96字
- 2021-07-02 21:50:12
Functional bean declaration DSL
In Spring, we register our beans either using XML or the @Configuration and @Bean annotations. When Spring Boot is used from Kotlin, there is a new alternative to declare the beans using lambdas, which act as FactoryBean.
Registering beans in Java:
GenericApplicationContext context = new
GenericApplicationContext();
context.registerBean(Message.class);
With DSL style and reified type parameters, the Kotlin equivalent is as simple and beautiful as the following:
beans {
bean<Message>()
}
Now that we understand the key constructs of Kotlin while building Spring Boot applications, let's move on to the example application.
推薦閱讀
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- JavaScript 從入門到項(xiàng)目實(shí)踐(超值版)
- Learning Data Mining with Python
- Web交互界面設(shè)計(jì)與制作(微課版)
- Visual Basic程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)(第二版)
- HTML5從入門到精通(第4版)
- Programming with CodeIgniterMVC
- R用戶Python學(xué)習(xí)指南:數(shù)據(jù)科學(xué)方法
- Android移動(dòng)應(yīng)用項(xiàng)目化教程
- Mastering Embedded Linux Programming
- SAS編程演義
- Splunk Essentials
- 深入大型數(shù)據(jù)集:并行與分布化Python代碼
- 計(jì)算機(jī)軟件項(xiàng)目實(shí)訓(xùn)指導(dǎo)
- Web程序設(shè)計(jì)與架構(gòu)