如何将 Liferay DXP 与 Apache POI 集成?

Ash*_*ich 2 excel apache-poi build.gradle liferay-7 liferay-dxp

我正在尝试将 Apache POI 集成到Liferay DXP(OSGi) 中,但无法在 gradle 项目中解决与 POI 3.17 版本的依赖关系。我创建了以下 JAR 的独立项目:

  1. poi-3.17.jar
  2. poi-ooxml-3.17.jar
  3. poi-ooxml-schemas-3.17.jar
  4. xmlbeans-2.6.0.jar
  5. commons-collections4-4.1.jar

另外,我在build.gradle 中添加了以下 gradle 依赖

compile group: 'org.apache.poi', name: 'poi', version: '3.17'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17'
compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.17'
compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.6.0'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
Run Code Online (Sandbox Code Playgroud)

此外,bnd.bnd 中也提供了相应的 jar 。知道我在这里缺少什么吗?

Ash*_*ich 5

经过大量调查,我找到了 Liferay DXP 和 Apache POI 集成的解决方案和正确的依赖项管理。

在 build.gradle 中添加以下依赖项:

  • compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
  • compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
  • compile group: 'org.apache.poi', name: 'poi', version: '3.17'
  • compile group: 'org.apache.poi', name: 'poi-excelant', version: '3.17'
  • compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17'
  • compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.17'
  • compile group: 'org.apache.poi', name: 'poi-scratchpad', version: '3.17'
  • compile group: 'org.apache.poi', name: 'ooxml-schemas', version: '1.3'
  • compile group: 'org.apache.poi', name: 'ooxml-security', version: '1.1'
  • compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.6.0'

在 bnd.bnd 文件中添加以下属性

Include-Resource:\ @commons-collections4-4.1.jar,\ @commons-lang3-3.4.jar,\ @ooxml-schemas-1.3.jar,\ @ooxml-security-1.1.jar,\ @poi-3.17.jar,\ @poi-ooxml-3.17.jar,\ @poi-ooxml-schemas-3.17.jar,\ @poi-excelant-3.17.jar,\ @poi-scratchpad-3.17.jar,\ @xmlbeans-2.6.0.jar

Import-Package: \ !com.sun.*,\ !junit*,\ !org.apache.avalon.framework.logger,\ !org.apache.crimson.jaxp,\ !org.apache.jcp.xml.dsig.internal.dom,\ !org.apache.log,\ !org.apache.xml.resolver*,\ !org.bouncycastle.*,\ !org.gjt.xpp,\ !org.junit*,\ !org.relaxng.datatype,\ !org.xmlpull.v1,\ !com.graphbuilder*,\ *

一旦你在给定的文件中添加了这些属性。模块将成功部署并轻松地将 ApachePOI 集成到 Liferay DXP 中。