SpringBoot 2 migration ConfigurationProperties Failed to bind property to String[]

核能气质少年 提交于 2020-03-04 20:36:07

问题


I just migrate from Spring boot 1.5.8 to 2.0.0

I solved most of migration errors, but I have no idea for this:

@Configuration
public class LdapConfiguration {

    @Bean
    @ConfigurationProperties(prefix = "ldap")
    public LdapContextSource contextSource() {
        return new LdapContextSource();
    }

    @Bean(name = "ldapTemplate")
    public LdapTemplate ldapTemplate(ContextSource contextSource) {
        return new LdapTemplate(contextSource);
    }
}

My custom values (all variables are var env property, this is why the separator is "_"):

LDAP_URLS=ldaps://ldap-url.com:636/

Error :

Description:

Failed to bind properties under 'ldap.urls' to java.lang.String[]:

    Reason: Unable to get value for property urls

Action:

Update your application's configuration

looks like it can't bind my string value ldap.urls to String[], I tried with 2 values in my property separated by coma.

Any idea ?


回答1:


For some reason, Spring Boot can't bind to an array that is cloned. I've raised #12478 as I believe this is a regression in the new binder in 2.0.

Edit: this is now fixed as of Spring Boot 2.0.1



来源:https://stackoverflow.com/questions/49276037/springboot-2-migration-configurationproperties-failed-to-bind-property-to-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!