Polish "Improve LDAP auto-configuration conditions"
Closes gh-13143
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user