简体   繁体   中英

No converter found capable of converting from type [java.lang.String] to type [java.util.LinkedHashMap<java.lang.String, java.lang.String>]

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

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

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM