我有一个 grails 应用程序,/src/groovy 下的 groovy 具有 Java POI HSSF 的导入语句
例如
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.HSSFCellStyle
将 POI 添加到我的 grails 应用程序以便随 war 一起部署的最佳方式是什么?我尝试将 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 war 中产生此错误
java.lang.NoClassDefFoundError: _GrailsClasspath_groovy$_run_closure1
编辑:我的存储库有 maven,但仍然提示缺少类 def Read jars from lib folder in grails
最佳答案
在 Grails 中添加任何依赖项或插件时,如果使用纯 jar 名称,则必须遵循 maven 工件语义。例如,
runtime 'xmlbeans-2.3.0'
应该
runtime 'org.apache.xmlbeans:xmlbeans:2.3.0'
对应于
runtime '<groupId>:<artifactId>:<version>'
同样适用于所有其他依赖项和插件。一个一个地重写这些并从
lib
中删除所有 jars目录。随后清理并编译应用程序。
关于grails - 在 grails 应用程序中包含 POI 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24768739/