简体   繁体   English

SpringBoot 2迁移ConfigurationProperties无法将属性绑定到String []

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

I just migrate from Spring boot 1.5.8 to 2.0.0 我只是从Spring Boot 1.5.8迁移到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 "_"): 我的自定义值(所有变量均为var env属性,这就是分隔符为“ _”的原因):

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. 似乎无法将我的字符串值ldap.urls绑定到String [],我尝试用逗号分隔属性中的2个值。

Any idea ? 任何想法 ?

For some reason, Spring Boot can't bind to an array that is cloned. 由于某种原因,Spring Boot无法绑定到克隆的阵列。 I've raised #12478 as I believe this is a regression in the new binder in 2.0. 我提出了#12478,因为我相信这是2.0中新资料夹的回归。

Edit: this is now fixed as of Spring Boot 2.0.1 编辑:自Spring Boot 2.0.1起已修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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