I wrote an analyzer that specifically identifies troublesome spring scope mixtures. It has typically been run as a Unit/integration test within a project, since it inspects the running context for problems.
It probably needs a little tweaking for the latest generations of spring, but the source is here: https://github.com/krosenvold/spring-context-analyzer.git Kristian p.s. a number of people have reported this tool as "saving their bacon" 2014-11-25 9:39 GMT+01:00 Alexander Kriegisch <alexan...@kriegisch.name>: > FYI, Maven users: I have just added an answer [1] to the StackOverflow > question in order not to bloat the list here. My solution uses AspectJ. Maybe > there are better ways to do that, but for me it works. I use AspectJ anyway > and find it convenient to also do some rule enforcement during compilation > via "declare error" or "declare warning". > > [1] http://stackoverflow.com/a/27121947/1082681 > -- > Alexander Kriegisch > http://scrum-master.de > > > Niranjan Rao schrieb am 25.11.2014 04:01: > >> Since this was not a maven question directly, I tried posting this at >> stackoverflow first at >> https://stackoverflow.com/questions/27068654/how-to-enforce-verify-spring-scope-annotation-on-spring-beans. >> >> Did not get much traction. >> >> We do use spring and its dependency injection mechanism using >> annotations only. No XML files for spring. However the trouble starts >> when developers start mixing beans of different scopes - most of the >> time by accident. Many developers forget that beans are singleton in >> scope by default and end up creating beans (or services) that has state. >> They are happy because if it works on their machine but creates >> interesting mix/match of data when more than one user logs in to the >> application. >> >> Right now, I am thinking of simple solution - enforce that every spring >> component needs to have scope annotation also. Thought behind this is it >> will force developer to think about the scope by explicitly declaring >> the value. >> >> Are there any plugins that can do this? If not, can I extend maven >> enforcer plugin or findbugs in anyway to do this? Open to any other >> suggestions also. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org