升级单个grails项目lib jar文件的正确方法是什么? [英] What's the proper way to upgrade a single grails project lib jar file?

查看:57
本文介绍了升级单个grails项目lib jar文件的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我想升级到httpcore jar的较新版本(我有httpcore-4.0.1.jar,并且需要包含org.apache.http.entity.mime软件包的较新版本),而无需整个升级grails项目.

Specifically, I want to upgrade to a newer version of the httpcore jar (I have httpcore-4.0.1.jar and need a newer version that contains the org.apache.http.entity.mime package) without upgrading the entire grails project.

根据到目前为止的发现,最佳实践似乎指向在BuildConfig.groovy中的"dependencies"部分下进行操作,但是我还没有找到任何文档来说明我应该如何格式化依赖项声明(或甚至确认这是正确的选择).这似乎是我更熟悉的Rails项目的Gemfile,这就是为什么它是我目前正在寻找的地方.如果还有另一个更好的地方来定义它,请告诉我.

From what I've found so far, best practice seems to point to doing something in BuildConfig.groovy under the dependencies section, but I haven't found any documentation yet that explains how I should be formatting the dependency declaration (or even confirming that this would be the right place to do it). It seems to be the closest thing to a Rails project's Gemfile, which I'm more familiar with, which is why it's the place I'm currently looking to handle this. If there's another, better place to be defining that, please let me know.

我发现一些建议,可以将.jar文件简单地复制到lib文件夹中,然后将其拾取,但是我担心默认库的.jar文件可能会被覆盖和/或如果我正确地未正确注册,这样.

I've found some suggestions that .jar files can simply be copied into the lib folder and will be picked up, but I worry that .jar files for default libraries may be overwritten and/or not be registered correctly if I do it this way.

推荐答案

如果我正确理解,httpcore是Grails本身的依赖项,并且您想升级版本而不更改Grails本身的版本?您可以通过将以下内容添加到BuildConfig.groovy

If I understand correctly, httpcore is a dependency of Grails itself and you want to upgrade the version, without changing the version of Grails itself? You can do this by adding the following to BuildConfig.groovy

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // exclude the version of httpcore provided by Grails
        excludes 'httpcore'
    }

    dependencies { 
        // Use version 4.1.3 of the library instead
        compile 'org.apache.httpcomponents:httpcore:4.1.3'
    }
}

这篇关于升级单个grails项目lib jar文件的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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