LDAP 库的 Maven 依赖项无法在 OSGi 中解决 [英] Maven dependency for LDAP library could not be resolved in OSGi

查看:22
本文介绍了LDAP 库的 Maven 依赖项无法在 OSGi 中解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入

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>

在捆绑包中.

问题是

- 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 中使用吗?"

"How to resolve these dependencies? Which ldap dependency/library could be used in OSGi?"

目标 - 我正在尝试连接 LDAP

Objective - I'm trying to connect LDAP

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

参考 - LDAP 连接文档

推荐答案

你必须区分 build timeruntime 依赖.在 Maven 中,您定义了 构建时间 依赖项.默认情况下,它们与安装在 AEM 中的包(runtime 依赖项)没有任何关系.

You have to distinguish between build time and runtime dependencies. In Maven you define your build time dependencies. Per default they have nothing to do with the bundles installed in AEM (runtime dependencies).

说清楚:

在 Maven 中定义的依赖项不会自动安装到 AEM 中.

Dependencies defined in Maven are not automatically installed into AEM.

您可以通过多种方式部署将所需的运行时依赖项部署到 AEM:

There are a few options how you can deploy the required runtime dependencies to AEM:

  1. 手动安装(/system/console/bundles)
  2. 将它们放入内容包中并手动部署该内容包.
  3. 扩展您的 Maven 构建以创建一个内容包,其中包含您在运行时需要的包(例如 org.apache.directory.api:api-ldap-client-api:2.0.0.AM4)
  4. 使用硬盘上 AEM 的 install 目录安装捆绑包:crx-quickstart/install.
  1. Install them by hand (/system/console/bundles)
  2. Put them in a content package and deploy that content package by hand.
  3. Extend your Maven build to create a content-package which includes the bundles you need at runtime (e.g. org.apache.directory.api:api-ldap-client-api:2.0.0.AM4)
  4. Install the bundles using the install directory of AEM on the hard disk: crx-quickstart/install.

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

All of them have advantages and disadvantages. I usually opt for option #3. I have written a lengthy answer that explains this here: https://stackoverflow.com/a/56698917/190823

这篇关于LDAP 库的 Maven 依赖项无法在 OSGi 中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆