January 2019
Intermediate to advanced
392 pages
10h 11m
English
The default scope is always a singleton. This is a bean definition of the Spring IoC container that returns a single object instance in every object initialization. Here's a piece of code for the singleton scope:
<!-- A bean example with singleton scope --><bean id = "..." class = "..." scope = "singleton"/><!-- You can remove the scope for the singleton --><bean id = "..." class = "..."/>
Let's take a look at an example of a singleton scope.
Create a Spring project in the IDE. To do this, create two kt files and a bean XML configuration file under the src folder.
Here's a piece of the code of CreateUserGreeting.kt:
class UserGreeting { private var globalGreeting: String? = "Sasuke Uchiha" fun setGreeting(greeting: ...
Read now
Unlock full access