Liferay说,在Gradle中增加了依赖性;未解决的要求:进口包装“;
我编写了一个Liferay模块并成功部署了它 然后我在Liferay说,在Gradle中增加了依赖性;未解决的要求:进口包装“;,gradle,liferay,liferay-7,bnd,Gradle,Liferay,Liferay 7,Bnd,我编写了一个Liferay模块并成功部署了它 然后我在build.gradle的依赖项部分添加了这一行: compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3' 在运行/gradlew eclipse之后,我可以在eclipse中毫无问题地使用该库。但部署失败: 12:29:35,454 WARN [fileinstall-/home/nico/liferay/osgi/modu
build.gradle
的依赖项部分添加了这一行:
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
在运行/gradlew eclipse
之后,我可以在eclipse中毫无问题地使用该库。但部署失败:
12:29:35,454 WARN [fileinstall-/home/nico/liferay/osgi/modules][org_apache_felix_fileinstall:103] Error while starting bundle: file:/home/nico/liferay-dxp-digital-enterprise-7.0-sp3/osgi/modules/de.nico.mymodule-1.0.0.jar
org.osgi.framework.BundleException: Could not resolve module: de.nico.mymodule [1085]_ Unresolved requirement: Import-Package: org.apache.http; version="4.5.3"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:429)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)
我不知道为什么它在寻找org.apache.http
,而不是org.apache.httpcomponents
这是我的bnd.bnd
:
Bundle-SymbolicName: de.nico.mymodule
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
如何调查这个问题?
我不想手动下载/添加JAR。进一步的调查将从异常消息开始。它表示在运行时不存在以下要求:
导入包:org.apache.http;version=“4.5.3”
我假设它是以下之一:
- 您没有将httpcomponents(或您需要的版本..请参阅)库部署到Liferay(编译时,部署失败)
- httpcomponents可能不会打包为OSGi捆绑包。在这种情况下,您必须决定如何使代码可用。更多信息的良好起点是(感谢Andrea,从评论中宣传这一点)和
如何将这些依赖项添加到Liferay的运行时取决于您。如果依赖项是OSGi捆绑包,则可以直接下载和部署它们。如果它们不是OSGi捆绑包,请遵循链接文章中描述的技术之一。进一步的研究将从异常消息开始。它表示在运行时不存在以下要求:
导入包:org.apache.http;version=“4.5.3”
我假设它是以下之一:
- 您没有将httpcomponents(或您需要的版本..请参阅)库部署到Liferay(编译时,部署失败)
- httpcomponents可能不会打包为OSGi捆绑包。在这种情况下,您必须决定如何使代码可用。更多信息的良好起点是(感谢Andrea,从评论中宣传这一点)和
如何将这些依赖项添加到Liferay的运行时取决于您。如果依赖项是OSGi捆绑包,则可以直接下载和部署它们。如果它们不是OSGi捆绑包,请遵循链接文章中描述的技术之一。在您的bnd.bnd中
添加此代码
Import-Package:\
!org.apache.*,\
\
*
在你的字典里
添加此代码
Import-Package:\
!org.apache.*,\
\
*
还有一些关于它的官方文档:@AndreaDiGiorgi:我尝试了该页面上描述的内容,但得到的无法找到参数[{group=org.apache.httpcomponents,name=httpclient,version=4.5.3}]的compileInclude()方法在类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象上
@Olaf事实上,我没有“将httpcomponents部署到Liferay”,我认为gradle会将正确的东西包含到我的模块中。我发现,您是否建议我手动下载它及其许多依赖项,并将它们全部放入Liferay的deploy/文件夹?如果您在Liferay工作区中,您至少需要版本1.2.3。相反,如果您直接使用com.liferay.gradle.plugins
,则至少需要3.1.0版。为了以防万一,您应该尝试将Gradle插件更新到最新版本。@AndreaDiGiorgi:我在com.liferay.Gradle.plugins
设置为3.2.29
时遇到此错误。还有一些官方文档:@AndreaDiGiorgi:我尝试了该页面上描述的内容,但得到了找不到方法compileInclude()对于类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象上的参数[{group=org.apache.httpcomponents,name=httpclient,version=4.5.3}],实际上我没有“将httpcomponents部署到Liferay”,我认为gradle会将正确的东西包含到我的模块中。我发现,您是否建议我手动下载它及其许多依赖项,并将它们全部放入Liferay的deploy/文件夹?如果您在Liferay工作区中,您至少需要版本1.2.3。相反,如果您直接使用com.liferay.gradle.plugins
,则至少需要3.1.0版。以防万一,您应该尝试将Gradle插件更新到最新版本。@AndreaDiGiorgi:我在com.liferay.Gradle.plugins
设置为3.2.29
时遇到此错误。