如何在Liferay中以模块化方式使用第三方组件? [英] How to use a third-party component in a modular way in Liferay?

查看:320
本文介绍了如何在Liferay中以模块化方式使用第三方组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Liferay 7模块,它使用 org.apache.http.client.methods.HttpPost

I wrote a Liferay 7 module that uses org.apache.http.client.methods.HttpPost.

所以我下载了 httpclient-osgi JAR 并将其放入 deploy / ,但是当我尝试启动它时:

So I downloaded the httpclient-osgi JAR and put it in deploy/, but when I try to start it I get:

org.osgi.framework.BundleException: Could not resolve module: org.apache.httpcomponents.httpclient [1088]
  Unresolved requirement: Import-Package: org.apache.http; version="[4.4.0,4.5.0)"

所以我搜索了mvnrepository.com org.apache.http

问题:没有这样的组件存在。

So I searched mvnrepository.com for org.apache.http.
PROBLEM: No such component seems to exist.

除了,包括里面的课程我的Liferay模块


这样做听起来与OSGi原则相反:如果我的100个Liferay模块使用httpclient,那么在每个模块中都包含httpclient并不是很合理。

Do I have no other option than including the classes inside my Liferay module?
Doing so sounds contrary to the OSGi principles: if my 100 Liferay modules use httpclient then including httpclient in each of them does not sound very modular.

我在想错方法吗?

如何在Liferay中以模块化方式使用第三方组件?

Am I thinking the wrong way?
How to use a third-party component in a modular way in Liferay?

推荐答案

你正在搜索的是一个包名称而不是jar名称。
Apache httpclient需要httpcore。

What you are searching for is a package name not a jar name. Apache httpclient needs httpcore.

这些软件包可以很好地协同工作:

These bundles are known to work well together:

mvn:org.apache.httpcomponents/httpclient-osgi/4.5.3
mvn:org.apache.httpcomponents/httpcore-osgi/4.4.6

https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient-osgi/4.5.3

https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore-osgi/4.4.6

这篇关于如何在Liferay中以模块化方式使用第三方组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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