And if they are, How to stop that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the
scopeof thebeanbeing annotated. If it is of scopesingleton, then it the same instance will be used everywhere in the SpringApplicationContext. If it is of scopeprototype, then a new instance will be used in each location.These bean definitions coupled with the following code will help to illustrate.
Class1andClass2will receive a reference to the same instance ofsome.AnotherNewObject.Class3andClass4will receive references to different instances ofsome.NewObject.If you are using annotations and package scanning for configuration, then you can can use the
@Scopeannotation to specify your scope: