- 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.
推薦閱讀
- Android Wearable Programming
- CentOS 7 Server Deployment Cookbook
- Twilio Best Practices
- C語言程序設(shè)計教程
- 硅谷Python工程師面試指南:數(shù)據(jù)結(jié)構(gòu)、算法與系統(tǒng)設(shè)計
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- Hadoop 2.X HDFS源碼剖析
- 計算機(jī)應(yīng)用技能實(shí)訓(xùn)教程
- Mastering Elixir
- Selenium WebDriver Practical Guide
- 少兒編程輕松學(xué)(全2冊)
- VMware vRealize Orchestrator Essentials
- Unity與C++網(wǎng)絡(luò)游戲開發(fā)實(shí)戰(zhàn):基于VR、AI與分布式架構(gòu)
- 程序員的算法趣題2
- 計算機(jī)視覺增強(qiáng)現(xiàn)實(shí)應(yīng)用平臺開發(fā)