<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=kdburke" rel="nofollow">Kevin Burke</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7916?redirect=false" rel="nofollow">SPR-7916</a></strong> and commented</p>
<p dir="auto">When attempting to inject a bean created via the <em>util:map</em> tag into a service, an error results when the key type of the map is any thing other than <em>java.lang.String</em>.  I have specified the key type using the key-type attribute of the tag, but to no avail.</p>
<p dir="auto">The underlying Map that is required is <em>Map&lt;Integer, String&gt;</em>, but according to the <em>DefaultListableBeanFactory</em>, a hard check  of <em>String.isAssignableFrom(keyType)</em> is performed (line 753).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="else if (Map.class.isAssignableFrom(type) &amp;&amp; type.isInterface()) {
                  Class keyType = descriptor.getMapKeyType();
                  if (keyType == null || !String.class.isAssignableFrom(keyType)) {
                        if (descriptor.isRequired()) {
                              throw new FatalBeanException(&quot;Key type [&quot; + keyType + &quot;] of map [&quot; + type.getName() +
                                          &quot;] must be assignable to [java.lang.String]&quot;);"><pre class="notranslate"><code class="notranslate">else if (Map.class.isAssignableFrom(type) &amp;&amp; type.isInterface()) {
                  Class keyType = descriptor.getMapKeyType();
                  if (keyType == null || !String.class.isAssignableFrom(keyType)) {
                        if (descriptor.isRequired()) {
                              throw new FatalBeanException("Key type [" + keyType + "] of map [" + type.getName() +
                                          "] must be assignable to [java.lang.String]");
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.3</p>
<p dir="auto"><strong>Reference URL:</strong> <a href="http://forum.springsource.org/showthread.php?p=342130#post342130" rel="nofollow">http://forum.springsource.org/showthread.php?p=342130#post342130</a></p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398150499" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14040" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14040/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14040">#14040</a> Session not flushed with Hibernate 4.1.3, JTA and Spring transaction management integration (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=btiernay" rel="nofollow">Bob Tiernay</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4492?redirect=false" rel="nofollow">SPR-4492</a></strong> and commented</p>
<p dir="auto">The following branch in DefaultListableBeanFactory.resolveDependency requires that a dependency of interface type java.util.Map have java.lang.String as it's key type or it will fail:</p>
<p dir="auto">...<br>
else if (Map.class.isAssignableFrom(type) &amp;&amp; type.isInterface()) {<br>
Class keyType = descriptor.getMapKeyType();<br>
if (keyType == null || !String.class.isAssignableFrom(keyType)) {<br>
if (descriptor.isRequired()) {<br>
throw new FatalBeanException("Key type [" + keyType + "] of map [" + type.getName() +<br>
"] must be assignable to [java.lang.String]");<br>
}<br>
return null;<br>
}<br>
...</p>
<p dir="auto">This seems overly restrictive and is evinced when using <code class="notranslate">@Autowire</code>.  Is there some rationale for this contraint?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398113452" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13164" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13164/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13164">#13164</a> Support injection of collection-typed beans using <code class="notranslate">@Autowired</code>+<code class="notranslate">@Qualifier</code> or <code class="notranslate">@Inject</code>+<code class="notranslate">@Named</code></li>
</ul>