File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Map across application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Map across application" Watch "Map across application" New topic

Map across application

Navin Pillu
Ranch Hand

Joined: Apr 19, 2005
Posts: 103

We are using Spring 3.0. Here we want to use a HashMap. We want to initialize it when application loads at 1st time. Also it is modifiable at any time from any class. The modification should be available to all other classes across application whoever will use it.

Can any one suggest suitable strategy

Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

You can define a Map as a @Bean if you wish. But you can not use @Autowire to wire it into your beans, you must use @Resource or @Inject. This is due to the semantics of @Autowired. See

Note that HashMap is not thread safe. You might want to consider ConcurrentHashMap

[How To Ask Questions][Read before you PM me]
I agree. Here's the link:
subject: Map across application
It's not a secret anymore!