Inject Prototype Bean In Singleton Bean #springplatform #coding #javaframework

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

From what i can understand... Your prototype bean is actually a final type reference.. Which means youll never be able to change it.. And its present in a simgleton scope class.. Qhich means the object will be created once and returned wherever needed.. So once its declared.. It becomes final and then the singleton bean captures it..

priyankrajvansh
Автор

You are getting the same beans because you are using "dependency injection" by constructor.
Since you want to autowire a Prototype with a SingleTon, you should use dependency injection by setter.

antoinekeita
Автор

Внедрение зависимостей в синглтоны происходит на этапе работы контекста при инициализации. Это закономерно, что у синглтона единый прототайп, поскольку прототайп установлен был один раз в момент инициализации, а дальше спринг его не контролирует этот прототайп.

АртурКравченко-хб
Автор

So what's the solution to this boss?

shivarajme
Автор

First of all you are creating spring singleton class not java singleton class. Both are different right? Java singleton class you can access through static method you can not create an instance directly…

jalluvenubabu
Автор

Intrue question ❌
Interview question ✅


Very less people❌
Very few people ✅

Ahmad_
welcome to shbcf.ru