【问题标题】:Include POI libraries in grails app在 grails 应用程序中包含 POI 库
【发布时间】:2014-07-15 21:45:13
【问题描述】:

我有一个 grails 应用程序,并且 /src/groovy 下的 groovy 具有 Java POI HSSF 的导入语句 例如

import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.HSSFCellStyle

将 POI 添加到我的 grails 应用程序以便它与战争一起部署的最佳方式是什么。我尝试将 jars 添加到 /lib,然后将它们作为运行时依赖项添加到 BuilConfig.groovy 中。

dependencies {
     runtime 'mysql:mysql-connector-java:5.1.22'
     runtime 'poi-3.9-20121203'
     runtime 'poi-ooxml-3.9'
     runtime 'poi-ooxml-schemas-3.9'
     runtime 'xml-apis-ext-1.3.04'
     runtime 'xmlbeans-2.3.0'
     runtime 'xmlpull-1.1.3.1'
     runtime 'xstream-1.4.7'
}

我也试过以这种方式将它添加为编译插件

plugins {
        runtime ":hibernate:3.6.10.13"       
        compile ":excel-import:1.0.0"
}

两者都在 grails 战争中产生此错误

java.lang.NoClassDefFoundError: _GrailsClasspath_groovy$_run_closure1

编辑:我的存储库有 maven,但仍然抱怨缺少 class def Read jars from lib folder in grails

【问题讨论】:

    标签: grails groovy apache-poi


    【解决方案1】:

    在 Grails 中添加任何依赖项或插件时,如果使用纯 jar 名称,则必须遵循 maven 工件语义。例如,

    runtime 'xmlbeans-2.3.0'
    

    应该是

    runtime 'org.apache.xmlbeans:xmlbeans:2.3.0'
    

    对应于

    runtime '<groupId>:<artifactId>:<version>'
    

    同样适用于所有其他依赖项和插件。一个一个地重写这些并从lib 目录中删除所有jar。随后清理并编译应用程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-06
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-13
      • 2018-01-05
      相关资源
      最近更新 更多