util:map in Spring picking up every bean of the map type

I have a Spring map problem that is bringing me to tears.

My spring looks like this:

<?xml version="1.0" encoding="UTF-8"?>
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd

   <util:map id="mockMap">
        <entry key="userTest1" value="test1"/>
        <entry key="userTest2" value="test2"/>
        <entry key="userTest3" value="test6"/>

Then the code where I am autowiring this is as follows (irrelevant parts ommitted):

Map<String, String> testMap;

public void testGetGearListActivityOK() {
    for (String key : testMap.keySet()) {
        System.out.println("key = " + key);

Amazingly enough, this will actually give me an error on the autowiring step saying that there are no beans matching type String. However, if I change the map in the unit-test to be defined as Map then I get the follow output:

[junit] key = mockMap
[junit] key = org.springframework.context.annotation.internalConfigurationAnnotationProcessor
[junit] key = org.springframework.context.annotation.internalAutowiredAnnotationProcessor
[junit] key = org.springframework.context.annotation.internalRequiredAnnotationProcessor
[junit] key = org.springframework.context.annotation.internalCommonAnnotationProcessor
[junit] key = systemProperties
[junit] key = systemEnvironment
[junit] key = messageSource
[junit] key = applicationEventMulticaster
[junit] key = lifecycleProcessor

I have not yet been able to get the key section of the entry to actually show up as a key. If I change the map back to Map and add some into my spring then the map populates with those, using their id's as the keys.

I'm so confused here and have used spring a decent amount in the past. If anyone has a clue what the heck is going on here I'd be very grateful.

Thanks in advance.

Also, I saw this question: Auto-wiring a List using util schema gives NoSuchBeanDefinitionException

But the solution there is to use @Resource, which I am already doing..


Remove @Autowired and only use the @Resource(name="mockMap")

Need Your Help

Math equations returning 0 when using variables between classes

java class math subclass parent

My final result when testing these classes returns zero/zero, but it should return an actual answer.

How to http post byte array or string as file in C#

c# post file-upload webclient

I need to post xml string as file. Here is my code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.