Liferay如何模块化的使用第三方组件?
How to use a third-party component in a modular way in Liferay?
我编写了一个使用 org.apache.http.client.methods.HttpPost 的 Liferay 7 模块。
所以我下载了 httpclient-osgi JAR 并将其放入 deploy/
,但是当我尝试启动它时,我得到:
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
。
问题:似乎不存在这样的组件。
除了including the classes inside my Liferay module我别无选择吗?
这样做听起来违反了 OSGi 原则:如果我的 100 个 Liferay 模块使用 httpclient,那么在每个模块中包含 httpclient 听起来不是很模块化。
我是不是想错了?
Liferay如何模块化的使用第三方组件?
您要搜索的是包名称,而不是 jar 名称。
Apache httpclient 需要 httpcore。
众所周知,这些捆绑包可以很好地协同工作:
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
我编写了一个使用 org.apache.http.client.methods.HttpPost 的 Liferay 7 模块。
所以我下载了 httpclient-osgi JAR 并将其放入 deploy/
,但是当我尝试启动它时,我得到:
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
。
问题:似乎不存在这样的组件。
除了including the classes inside my Liferay module我别无选择吗?
这样做听起来违反了 OSGi 原则:如果我的 100 个 Liferay 模块使用 httpclient,那么在每个模块中包含 httpclient 听起来不是很模块化。
我是不是想错了?
Liferay如何模块化的使用第三方组件?
您要搜索的是包名称,而不是 jar 名称。 Apache httpclient 需要 httpcore。
众所周知,这些捆绑包可以很好地协同工作:
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