Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Thank you for the litterature, it will take me a while to read :) BTW I added a relevant piece of code. Commented Jan 24, 2018 at 8:22
  • 1
    Having static beans would mean you call them whenever you want, This doesn't remove either coupling nor dependency. It only will obfuscate it and, over time, the coupling and the dependency over these beans will go for worse. When a component is present anywhere in the code, it's a design flaw regarding cohesion. Statics will act like global variables what in general, is a bad thing. Mainly because makes the whole application less predictive. Overall if these beans are stateful Commented Jan 24, 2018 at 10:10
  • I think one of the main points there (that I missed) would be that states on beans are strictly to banish. Commented Jan 25, 2018 at 13:18
  • 2
    Though I mostly agree with that, I fail to see the point about memory consumption, since a Spring Beans will generally eager instantiated at startup and will remain in memory as a singleton unless you specify otherwise. Commented Jan 11, 2019 at 12:10
  • @Walfrat, I was explaining generally the problem, but you are right, Spring Beans are singleton by default. I added this explanation on my answer, thanks! Commented Jan 11, 2019 at 14:45