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

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

问题描述

我正在尝试导入

  import org.apache.commons.pool2.impl.GenericObjectPool;导入org.apache.commons.pool2.impl.GenericObjectPoolConfig;导入org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory;导入org.apache.directory.ldap.client.api.LdapConnection;导入org.apache.directory.ldap.client.api.LdapConnectionConfig;导入org.apache.directory.ldap.client.api.LdapConnectionPool;导入org.apache.directory.ldap.client.api.ValidatingPoolableLdapConnectionFactory;导入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中.

问题是

 -构建后,osgi中不存在工件-由于错误,项目捆绑包处于保存状态org.apache.commons.pool2,version = [2.6,3)-无法解析org.apache.commons.pool2.impl,version = [2.6,3)-无法解决org.apache.directory.ldap.client.api,version = [2.0,3)-无法解析org.apache.directory.ldap.client.template,version = [2.0,3)-无法解析 

更新的问题-

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

目标-我正在尝试连接LDAP

  LdapConnection连接= new LdapNetworkConnection("localhost",10389); 

参考- LDAP连接文档

解决方案

您必须区分构建时间运行时依赖项.在Maven中,您定义您的构建时间依赖项.默认情况下,它们与AEM中安装的捆绑软件无关(运行时依赖项).

为清楚起见:

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

有几种方法可以部署所需的运行时依赖于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 .

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

I am trying to import

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;

and using

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

in the parent pom and

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

in the bundle pom.

The issue is

- 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

UPDATED QUESTION -

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

Objective - I'm trying to connect LDAP

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

Reference - LDAP Connection documentation

解决方案

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).

To make it clear:

Dependencies defined in Maven are not automatically installed into AEM.

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

  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.

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天全站免登陆