October 2017
Intermediate to advanced
396 pages
10h 2m
English
To declare a bean in a Java-based configuration, you have to write a method for the desired type object creation in the configuration class, and annotate that method with @Bean. Let's see the following changes made in the AppConfig class to declare the beans:
package com.packt.patterninspring.chapter4.bankapp.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class AppConfig { @Bean public TransferService transferService(){ return new TransferServiceImpl(); } @Bean public AccountRepository accountRepository() { return new JdbcAccountRepository(); } @Bean public TransferRepository transferRepository() ...Read now
Unlock full access