I have to load something from the database to initialize a hashMap object that I want to add to a application wide variable that all my mvc controllers can access.
I won’t be modifying this object, and I don’t care if it can only be updated when the application reloads.
Does spring MVC have a place where I can do this and have spring manage the lifecycle also?
I know servlets has the WebListener annotation:
@WebListener
But not sure if spring has this also (wrapped in their iOc container).
I think the best place is to declare a bean like the following:
Then you declare that bean in your xml file, if you don’t like the annotation, there are non-annotation approaches for initializing a bean, but that gets executed when the spring context starts.