Petteri H
Petteri H

Reputation: 12232

Spring util:map injection with @resource

This should be simple but I don't manage to get it working.

I have field annotated with @resource:

public class foo {
  @Resource(name = "configMap")
  private Map<String, String> config;
}

In applicationContext.xml I have (to be populated with Maven:

<context:annotation-config />
<util:map id="configMap" map-class="java.util.HashMap">
    <entry key="url" value="${url}"></entry>
</util:map>

But at run time this doesn't work, the config field remains null. Any advices?

Edit: I am using Spring 3.0 and it is an existing project so I can't tell right away if there is some bizarre config elsewhere preventing this from working.

Upvotes: 1

Views: 5146

Answers (2)

Petteri H
Petteri H

Reputation: 12232

As waxwing suggested, the instance was not created properly.

Upvotes: 0

Have You included the context name space to your beans definition ?

xmlns:context="http://www.springframework.org/schema/context"

Upvotes: 1

Related Questions