- 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.
推薦閱讀
- HBase從入門到實戰(zhàn)
- 人人都是網(wǎng)站分析師:從分析師的視角理解網(wǎng)站和解讀數(shù)據(jù)
- Java設計模式及實踐
- PostgreSQL Replication(Second Edition)
- Java EE 8 Application Development
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- Android嵌入式系統(tǒng)程序開發(fā):基于Cortex-A8(第2版)
- Hadoop 2.X HDFS源碼剖析
- Hadoop大數(shù)據(jù)分析技術
- Java Web開發(fā)實例大全(基礎卷) (軟件工程師開發(fā)大系)
- SignalR:Real-time Application Development(Second Edition)
- Unity Android Game Development by Example Beginner's Guide
- INSTANT Apache Hive Essentials How-to
- Mastering ASP.NET Web API
- Learning GraphQL and Relay