【发布时间】:2018-08-22 21:09:57
【问题描述】:
我刚刚从 Spring boot 1.5.8 迁移到 2.0.0
我解决了大部分迁移错误,但我对此一无所知:
@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 属性,这就是分隔符是“_”的原因):
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 个由逗号分隔的值。
有什么想法吗?
【问题讨论】:
-
在 application.properties 中尝试使用 ldap.urls 而不是 LDAP_URLS
-
所有变量都是var env属性,这就是为什么分隔符是“_”,我没有application.properties。它适用于我的所有其他价值观
-
啊好吧!您是否尝试过阵列方式?看这里github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0
-
也许你在 Spring Boot 2 中发现了一个错误:P
-
感谢您的帮助!在打开问题之前我会在这里等待 Spring Boot 团队
标签: java spring spring-boot spring-ldap