无法在 OSGi 中解决 LDAP 库的 Maven 依赖关系

2024-04-12

我正在尝试导入

import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
import org.apache.directory.ldap.client.api.LdapConnectionPool;
import org.apache.directory.ldap.client.api.ValidatingPoolableLdapConnectionFactory;
import org.apache.directory.ldap.client.template.LdapConnectionTemplate;

并使用

<dependency>
    <groupId>org.apache.directory.api</groupId>
    <artifactId>api-ldap-client-api</artifactId>
    <version>2.0.0.AM4</version>
</dependency>

在父 pom 中和

<dependency>
    <groupId>org.apache.directory.api</groupId>
    <artifactId>api-ldap-client-api</artifactId>
</dependency>

在捆绑 pom 中。

问题是

- The artifact is not present in osgi after build and
- Project bundle is in resoved state due to error 

org.apache.commons.pool2,version=[2.6,3) -- Cannot be resolved
org.apache.commons.pool2.impl,version=[2.6,3) -- Cannot be resolved
org.apache.directory.ldap.client.api,version=[2.0,3) -- Cannot be resolved
org.apache.directory.ldap.client.template,version=[2.0,3) -- Cannot be resolved

更新的问题 -

“如何解决这些依赖关系?哪个ldap依赖/库 可以在 OSGi 中使用吗?”

目标 - 我正在尝试连接 LDAP

LdapConnection connection = new LdapNetworkConnection( "localhost", 10389 );

参考 -LDAP 连接文档 https://directory.apache.org/api/user-guide/2.1-connection-disconnection.html


你必须区分构建时间 and runtime依赖关系。在 Maven 中你定义你的构建时间依赖关系。默认情况下他们有nothing与 AEM 中安装的捆绑包有关(runtime依赖项)。

为了明确起见:

Maven 中定义的依赖关系是not自动安装到 AEM 中。

有几个选项可以帮助您deploy所需runtime对 AEM 的依赖关系:

  1. 手动安装它们(/system/console/bundles)
  2. 将它们放入内容包中并手动部署该内容包。
  3. 扩展您的 Maven 构建以创建一个内容包,其中包括您在运行时所需的捆绑包(例如org.apache.directory.api:api-ldap-client-api:2.0.0.AM4)
  4. 使用以下命令安装捆绑包install硬盘上AEM的目录:crx-quickstart/install.

它们都有优点和缺点。我通常选择选项#3。我写了一篇很长的答案,在这里解释了这一点:https://stackoverflow.com/a/56698917/190823 https://stackoverflow.com/a/56698917/190823

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 OSGi 中解决 LDAP 库的 Maven 依赖关系 的相关文章

随机推荐