No converter found capable of converting from type [java.lang.String] to type [java.util.LinkedHashMap<java.lang.String, java.lang.String>]
10,420
Solution 1
@ConfigurationProperties can't map LinkedHashMap from you properties. You have to use SpEL which is not supported as mentioned here
To solve your issue could update the configuration by adding @Value annotation eg.:
@Getter
@Setter
@Component
public class ShiroConfiguration {
@Value("#{${shiro.filter-chain-definitions}}")
private LinkedHashMap<String, String> filterChainDefinitions;
}
Solution 2
The special characters(/
, *
) in the key are throwing the binding off. Map keys with special characters need to be surrounded with square brackets. The below should work:
shiro:
filterChainDefinitions:
'[/**]': origin
Author by
Admin
Updated on June 25, 2022Comments
-
Admin almost 2 years
spring boot 2.1.1 can not read yml config to LinkedHashMap
this is my class
I've provided get and set functions. But it doesn't work.
@Getter @Setter @Configuration @ConfigurationProperties("shiro") public class ShiroConfiguration { private LinkedHashMap<String, String> filterChainDefinitions; }
this is my config
shiro: filterChainDefinitions: /**: origin
this is error message
Description: Failed to bind properties under 'shiro.filter-chain-definitions' to java.util.LinkedHashMap<java.lang.String, java.lang.String>: Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.LinkedHashMap<java.lang.String, java.lang.String>] Action: Update your application's configuration
-
Admin over 5 yearsI've provided get and set functions. But it doesn't work.
-
mad_fox over 5 yearsDid you add
@EnableConfigurationProperties
? -
Admin over 5 yearsI didn't do it, Except map other is normal
-
Admin over 5 yearsRename the variable , It does not work too, spring boot 1.5.* is no problem。