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: [email protected] For additional commands, e-mail: [email protected]
