Java 无法在ldif文件的帮助下将示例数据加载到ldap服务器
我需要将批量数据插入LDAP服务器,因为我使用了LdapTestUtils 类,但出现了一些错误 梯度依赖Java 无法在ldif文件的帮助下将示例数据加载到ldap服务器,java,spring-boot,spring-ldap,unboundid-ldap-sdk,Java,Spring Boot,Spring Ldap,Unboundid Ldap Sdk,我需要将批量数据插入LDAP服务器,因为我使用了LdapTestUtils 类,但出现了一些错误 梯度依赖 dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-ldap' testImplementation 'org.springframework.boot:spring-boot-starter-test' testCompile group: 'org.sp
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testCompile group: 'org.springframework.ldap', name: 'spring-ldap-test', version: '2.3.2.RELEASE'
}
Java代码
public static void loadData() throws Exception
{
// Bind to the directory
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:10389");
contextSource.setUserDn("uid=admin,ou=system");
contextSource.setPassword("secret");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName("dc=example,dc=com"));
LdapTestUtils.loadLdif(contextSource, new ClassPathResource("schema.ldif"));
}
链接-
第一个例子
错误-无法解析org.apcahe.directory.server.core它是从require.class文件间接引用的
我错过了什么?
还有其他办法吗
public static void loadData() throws Exception
{
// Bind to the directory
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:10389");
contextSource.setUserDn("uid=admin,ou=system");
contextSource.setPassword("secret");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("dn to remove"),
new ClassPathResource("schema.ldif"));
}
cleanAndSetup方法对我有效,但它也会重新启动服务器请发布完整的错误日志。与我显示的编译时错误相同