3

我正在尝试将 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'

此外,bnd.bnd中也提供了相应的 jar。任何线索我在这里错过了什么?

4

2 回答 2

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。

于 2017-10-29T19:50:32.587 回答
0

下面是 apache-poi-4.0.0 和 Liferay 7 的 osgi 包文件(bnd.bnd)。不幸的是,您的 portlet jar 文件至少有 27MB。必须使用 Blade Client 部署一些常用库

java -jar blade.jar sh start http://repo1.maven.org/maven2/org/apache/commons/commons-collections4/4.2/commons-collections4-4.2.jar
java -jar blade.jar sh start http://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar
java -jar blade.jar sh start http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.8/commons-lang3-3.8.jar
java -jar blade.jar sh start http://repo1.maven.org/maven2/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
java -jar blade.jar sh start http://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar

Bundle File:    

Bundle-Name: [your-bundle-name]
Bundle-SymbolicName: [your-bundle-symbolicname]
Bundle-Version: 1.0
-jsp: *.jsp,*.jspf
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
-plugin.resourcebundle: 
com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
-plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin
-sass: *

Import-Package:\
    !com.sun.*, \
    !com.graphbuilder*, \
    !org.apache.jcp.xml.dsig.internal.dom, \
    !org.bouncycastle.*, \
    *

Include-Resource:\
    @poi-4.0.0.jar, \
    @poi-excelant-4.0.0.jar, \
    @poi-ooxml-4.0.0.jar, \
    @poi-ooxml-schemas-4.0.0.jar, \
    @poi-scratchpad-4.0.0.jar, \
    @ooxml-schemas-1.4.jar, \
    @ooxml-security-1.1.jar, \
    @xmlbeans-3.0.1.jar
于 2018-10-02T13:38:52.380 回答