问题描述
我只是从 Spring boot 1.5.8 迁移到 2.0.0
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);
}
}
我的自定义值(所有变量都是 var env 属性,这就是分隔符是_"的原因):
My custom values (all variables are var env property, this is why the separator is "_"):
LDAP_URLS=ldaps://ldap-url.com:636/
错误:
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
看起来它无法将我的字符串值 ldap.urls 绑定到 String[],我尝试在我的属性中使用 2 个值,用 coma 分隔.
looks like it can't bind my string value ldap.urls to String[], I tried with 2 values in my property separated by coma.
有什么想法吗?
推荐答案
出于某种原因,Spring Boot 无法绑定到克隆的数组.我提出了 #12478 因为我相信这是一个回归2.0 中的新活页夹.
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.
现在从 Spring Boot 2.0.1 开始修复
this is now fixed as of Spring Boot 2.0.1
这篇关于SpringBoot 2 迁移 ConfigurationProperties 无法将属性绑定到 String[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!