如何添加“非 mavenized"对 grails 项目的 jar 依赖 [英] How to add a "non-mavenized" jar dependency to a grails project
问题描述
我是 grails 新手.我在 Windows 7 上从命令行(无 IDE)使用 grails 2.0.3.
I'm a grails newby. I am using grails 2.0.3 from the command line (no IDE) on windows 7.
我只是在运行 grails 文档中的hello world"示例.
I am just running the 'hello world' example from the grails documentation.
我有一个不在 maven 中的自定义 jar,我想在我的项目中使用它.我将它添加到 lib 文件夹并进行了刷新依赖.我修改了控制器以从 jar 导入一个类.当我执行 'run-app' 时,编译器抱怨它找不到类.
I have a custom jar that is not in maven that I would like to use in my project. I added it to the lib folder and did a refresh-dependencies. I modified the controller to import a class from the jar. When I did 'run-app', the compiler complained that it could not find the class.
我在网上看到了几个例子,人们必须像这样在他们的 BuildConfig.groovy 中添加一行: runtime 'httpclient:httpclient:3.0.1' .但是由于我没有使用 maven 或 ivy,我如何在我的类路径上获取那个 jar 包?
I saw several example online where people had to add a line to their BuildConfig.groovy like this: runtime 'httpclient:httpclient:3.0.1' . But since I'm not using maven or ivy, how do I get that jar on my classpath?
我上面提到的例子是 http://grails.1312388.n4.nabble.com/External-Jar-in-Grails-td4388010.html
推荐答案
Grails 2.0-2.2
好的,我终于知道我需要做什么了.假设我的 jar 名为mylib.jar".我需要将它重命名为 mylib-1.0.jar 并将其移动到 lib 目录.然后我需要在 BuildConfig.groovy 中添加以下内容:
Ok, I finally figured out what I need to do. Suppose my jar is named 'mylib.jar'. I need to rename it to mylib-1.0.jar and move it to the lib directory. Then I need to add the following to BuildConfig.groovy:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.16'
runtime 'mylib:mylib:1.0'
}
我想这对除了我之外的每个人都很明显.希望这对其他人有帮助.
I guess that was obvious to everyone but me. Hope this helps someone else.
Grails 2.3-...
只需将一个 jar 放入 lib/
.不要修改BuildConfig.groovy
(c) kaskelotti
Just put a jar into the lib/
. Do not modify BuildConfig.groovy
(c) kaskelotti
这篇关于如何添加“非 mavenized"对 grails 项目的 jar 依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!