<p>We are using Spring Boot 2.</p>

<p>We want to use the refresh mechanism of Spring Boot, but due to a bug we can't use <code>@Configuration</code>, hence we are forced to replace all theses by <code>@Value</code> in combination with <code>@RefreshScope</code>.</p>

<p>So we used that:</p>

<pre><code>@Configuration
@RefreshScope
public class MyConfig {
     @Value("${myMap}")
    private Map&lt;String, String&gt; myMap;
}
</code></pre>

<p>With that YAML file for example:</p>

<pre><code>myMaps:
  key1: Value
  key2: Another Value
</code></pre>

<p>But we get an error out of it:</p>

<blockquote>
  <p>Error creating bean with name 'scopedTarget.myMap': Unsatisfied dependency expressed through field 'mapMap'; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Map'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Map': no matching editors or conversion strategy found</p>
</blockquote>

<p>We found already other thread with a similar topic:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/28369458/how-to-fill-hashmap-from-java-property-file-with-spring-value">How to fill HashMap from java property file with Spring @Value</a></li>
<li><a href="https://stackoverflow.com/questions/30691949/how-to-inject-a-map-using-the-value-spring-annotation">How to inject a Map using the @Value Spring Annotation?</a></li>
</ul>

<p>But we can't use other kind of property bindings, as we are deploying this app into kubernetes and use the config maps of kubernetes.</p>

<p>So we wonder, if there is any other chance to get <code>@Value</code> working together with <code>Map</code></p>

Michael D.
<p>Instead of: <code>@Value(&quot;${myMap}&quot;)</code>, you need to write like this <code>@Value(&quot;#{${myMap}}&quot;)</code>.</p>
<hr />
<p>'#' treat whats in the curly bracket after it as Spring Expression Language(SpEL).</p>
