Polish "Improve LDAP auto-configuration conditions"

Closes gh-13143
This commit is contained in:
Stephane Nicoll
2018-05-11 17:48:29 +02:00
parent dfceede0bc
commit 8e9a873787
2 changed files with 7 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
@@ -120,7 +121,6 @@ public class LdapAutoConfigurationTests {
"urls");
assertThat(urls).containsExactly("ldap://localhost:389");
assertThat(contextSource.isAnonymousReadOnly()).isFalse();
context.getBean(PooledContextSource.class);
});
}
@@ -128,6 +128,7 @@ public class LdapAutoConfigurationTests {
static class PooledContextSourceConfig {
@Bean
@Primary
public PooledContextSource pooledContextSource(
LdapContextSource ldapContextSource) {
PooledContextSource pooledContextSource = new PooledContextSource(

View File

@@ -4539,6 +4539,11 @@ URLs of your server in your application.properties, as shown in the following ex
If you need to customize connection settings, you can use the `spring.ldap.base` and
`spring.ldap.base-environment` properties.
A `LdapContextSource` is auto-configured based on these settings. If you need to customize
it, for instance to use a `PooledContextSource`, you can still inject the auto-configured
`LdapContextSource`. Make sure to flag your customized `ContextSource` as `@Primary` so
that the auto-configured `LdapTemplate` uses it.
[[boot-features-ldap-spring-data-repositories]]