外部LDAP服务器和嵌入式LDAP服务器之间确实没有太大的区别。在配置LdapContextSource
时,您必须将服务器的url设置为ldap://localhost:33389/
(假设您的嵌入式服务器在端口33389处侦听)。
请注意,默认情况下,UnboundID InMemoryDirectoryServer
将在运行时随机选择一个空闲端口,除非您将其配置为侦听修复端口。这可能会帮助你入门:
InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig("dc=example, dc=com");
// make sure that the server listens on port 33389
config.setListenerConfigs(
new InMemoryListenerConfig("myListener", null, 33389, null, null, null));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.startListening();
// import some test data from an ldif file
ds.importFromLDIF(true,"content.ldif");
谢谢@zagyi :)它似乎工作! – SolutionMill 2013-02-19 17:45:53
不客气! :)如果解决方案有效,我是否可以请你接受并且可能upvote我的答案?我只是问这个,因为我看到你是一个新用户。 :) – zagyi 2013-02-19 18:26:00