无法借助 ldif 文件将示例数据加载到 ldap 服务器

Unable to load sample data into ldap Server with the help of ldif file

为此我需要将批量数据插入 LDAP 服务器我使用了 LdapTestUtils class 但出现一些错误

Gradle 依赖关系

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"));
    }

Link - https://www.programcreek.com/java-api-examples/index.php?api=org.springframework.ldap.test.LdapTestUtils 第一个例子

错误 - 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 方法对我有用,但它也会重启服务器