由于您对该类的唯一用途LdapCtxFactory是配置设置
env.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName());
Run Code Online (Sandbox Code Playgroud)
LdapCtxFactory.class.getName()您可以通过替换为限定名称来删除对类的依赖关系"com.sun.jndi.ldap.LdapCtxFactory",即
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
Run Code Online (Sandbox Code Playgroud)