From 95422528ac8aa549875c5523de983112afc3019f Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 19 Jan 2021 12:26:25 +0000 Subject: [PATCH] Explicitly define Bean Scope --- Spring/src/main/java/conference/AppConfig.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Spring/src/main/java/conference/AppConfig.java b/Spring/src/main/java/conference/AppConfig.java index ee7e305..ce759a8 100644 --- a/Spring/src/main/java/conference/AppConfig.java +++ b/Spring/src/main/java/conference/AppConfig.java @@ -4,14 +4,17 @@ import conference.repository.HibernateSpeakerRepositoryImpl; import conference.repository.SpeakerRepository; import conference.service.SpeakerService; import conference.service.SpeakerServiceImpl; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; @Configuration public class AppConfig { @Bean(name = "speakerService") + @Scope(value = BeanDefinition.SCOPE_SINGLETON) public SpeakerService getSpeakerService() { return new SpeakerServiceImpl(getSpeakerRepository()); }