January 2018
Intermediate to advanced
414 pages
10h 29m
English
So far, we have used @Component or @Service to declare our beans that later on, when the SpringBoot application starts, will add to the Spring context by the component scan. However, we may want to explicitly declare our beans using a Configuration class:
import org.springframework.context.annotation.Beanimport org.springframework.context.annotation.Configuration@Configurationclass ContextConfiguration { @Bean fun accountService() = AccountService() @Bean fun customerService(accountService: AccountService) = CustomerService(accountService) @Bean fun customerController(customerService: CustomerService) = CustomerController(customerService)}
Since we now have a constructor injection, we need to specify our bean ...
Read now
Unlock full access