【发布时间】:2014-11-18 04:32:04
【问题描述】:
我有一个需要执行 LDAP 查询的 Spring Boot 应用程序。我正在尝试从 Spring Boot 文档中获取以下建议:
“很多Spring配置示例已经发布在 使用 XML 配置的 Internet。始终尝试使用等效的 如果可能,基于 Java 的配置。”
在 Spring XML 配置文件中,我会使用:
<ldap:context-source
url="ldap://localhost:389"
base="cn=Users,dc=test,dc=local"
username="cn=testUser"
password="testPass" />
<ldap:ldap-template id="ldapTemplate" />
<bean id="personRepo" class="com.llpf.ldap.PersonRepoImpl">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
如何使用基于 Java 的配置进行配置?我需要能够更改 ldap:context-source 的 URL、base、用户名和密码属性,而无需重新构建代码。
【问题讨论】: