在grails中从lib文件夹读取jar文件 [英] Read jars from lib folder in grails

查看:379
本文介绍了在grails中从lib文件夹读取jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Apache POI库解析excel文件,将开发模式下的一些数据引导到我的grails 2.0.1应用程序。



我试过使用Grails excel-import插件,但插件会在我执行运行应用程序

因为这个原因,我决定现在就不用插件了。首先,我将下一个jar复制到grails应用程序库文件夹中。

  $ ls -la lib 
poi-3.7- 20101029.jar
poi-ooxml-3.7-20101029.jar
poi-ooxml-schemas-3.7-20101029.jar
xmlbeans-2.3.0.jar

我读过我应该在 grails-app / conf / BuildConfig.groovy 。因此,我添加了下一个:

 依赖关系{
//在'build','compile' ','运行时','测试'或'提供'范围,例如。
compile('org.apache.poi:poi:3.7','org.apache.poi:poi-ooxml:3.7')

// runtime'mysql:mysql-connector- java:5.1.16'
}

然而,当我执行run-app时,仍然无法找到罐子。

  grails>运行应用程序
|编译76个源文件

|编译30个源文件。
|错误编译错误:启动失败:
UMEExcelImporter.groovy:8:无法解析类org.apache.poi.xssf.usermodel.XSSFSheet
@ line 8,column 1.
import org。 apache.poi.xssf.usermodel.XSSFSheet
^

UMEExcelImporter.groovy:7:无法解析类org.apache.poi.xssf.usermodel.XSSFWorkbook
@ line 7 ,第1列。
import org.apache.poi.xssf.usermodel.XSSFWorkbook
^

UMEExcelImporter.groovy:9:无法解析类org.apache.poi.xssf .usermodel.XSSFRow
@ line 9,column 1.
import org.apache.poi.xssf.usermodel.XSSFRow

我没有使用任何IDE。欢迎任何反馈!

解决方案

POI罐子在公共Maven回购站点上,所以试试这个:


  1. 从您的lib文件夹中删除jar

  2. 清理您的版本: grails clean mavenCentral()included / uncommented
  3. >
  4. 您的依赖关系看起来不错(我还没有确认),所以现在尝试一下run-app

HTH

I want to parse an excel file using the Apache POI library to boot strap some data in development mode into my grails 2.0.1 application.

I've tried to use the Grails excel-import plugin but the plugin uninstalls automatically when I execute run-app.

Because of that I decided to got ahead without the plugin for now. First I have copied the next jars into the grails application lib folder

$ls -la lib
poi-3.7-20101029.jar
poi-ooxml-3.7-20101029.jar
poi-ooxml-schemas-3.7-20101029.jar
xmlbeans-2.3.0.jar

I've read that I should declare the dependency in grails-app/conf/BuildConfig.groovy. So, I added the next:

   dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
        compile ('org.apache.poi:poi:3.7', 'org.apache.poi:poi-ooxml:3.7')  

        // runtime 'mysql:mysql-connector-java:5.1.16'
    }

However when I execute run-app the application is still not able to find the jars.

grails> run-app
| Compiling 76 source files

| Compiling 30 source files.
| Error Compilation error: startup failed:
UMEExcelImporter.groovy: 8: unable to resolve class org.apache.poi.xssf.usermodel.XSSFSheet
 @ line 8, column 1.
   import org.apache.poi.xssf.usermodel.XSSFSheet
   ^

UMEExcelImporter.groovy: 7: unable to resolve class org.apache.poi.xssf.usermodel.XSSFWorkbook
 @ line 7, column 1.
   import org.apache.poi.xssf.usermodel.XSSFWorkbook
   ^

UMEExcelImporter.groovy: 9: unable to resolve class org.apache.poi.xssf.usermodel.XSSFRow
 @ line 9, column 1.
   import org.apache.poi.xssf.usermodel.XSSFRow

I am not using any IDE. Any feedback is welcome!

解决方案

The POI jars are on public Maven repo's so try this:

  1. Remove the jars from your lib folder
  2. Clean your build with: grails clean
  3. In you BuildConfig.groovy ensure that the "repositories" closure has "mavenCentral()" included/uncommented
  4. Your dependency looks ok (I have not confirmed it) so now try the run-app

HTH

这篇关于在grails中从lib文件夹读取jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆