问题
I wrote a Liferay 7 module that uses org.apache.http.client.methods.HttpPost.
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)"
So I searched mvnrepository.com for org.apache.http
.
PROBLEM: No such component seems to exist.
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.
Am I thinking the wrong way?
How to use a third-party component in a modular way in Liferay?
回答1:
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
来源:https://stackoverflow.com/questions/45185733/how-to-use-a-third-party-component-in-a-modular-way-in-liferay