在java中处理外部库的正确方法(使用eclipse) [英] The right way to deal with external libraries in java (using eclipse)

查看:232
本文介绍了在java中处理外部库的正确方法(使用eclipse)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对以前未回答的我的问题的追踪(链接),在过去几个星期中被淘汰,现在已经到了不能再发展的地步。

This is in a way a follow-up of a previously unanswered question of mine (link) which excalated over the past weeks, and now it has come to a point where I cant really develop anymore...

所以这里是交易;我比纯CS更多的数学/工程背景,所以我没有很多经验适合/大规模的软件开发,而是脚本和算法。现在我正在一个大型项目上工作,就我自己而言,与发展的一些方面相混淆。其中一个是处理库/依赖关系

So here's the deal; I have more of a mathematics/engineering background than pure CS, so I dont have a lot of experience with proper/large-scale software development, but rather scripting and algorithms. Now that I am working on a large project, on my own, I am confused with some of the aspects of development. One of them being handling libraries/dependencies

我最初创建了一个名为 lib 在我的项目文件夹(在Eclipse工作区)下,并复制我的外部库,然后将它们添加到构建路径。但是后来我需要一些其他的东西,如$ code> JCommons , JFreeChart Apache Commons Math etc ..根据说明,这些库可以/应该被包含为用户库,允许开发人员从IDE(如Eclipse)中查看文档和源代码。到目前为止,我已经得到了正确的一切,希望...

I have initially created a folder called lib under my project folder (in Eclipse workspace) and copied my external libraries in there and then added them to the build path. However later on I needed some other stuff like JCommons, JFreeChart, Apache Commons Math etc.. According to instructions these libraries can/should be included as user libraries, allowing the developer to see the documentation and source code from within IDE (such as Eclipse). I have gotten it right so far, I hope...

那么问题在哪里?首先,由于上述用户库不包括在项目的SVN副本中,这意味着我想要测试驱动我的项目的同事不能这样做,只需从SVN获取项目即可。现在第二阶段的问题在我工作站的工作站改变时并不重要,我想从我的备份将项目导入到Eclipse中,但是除了这些用户库之外的所有内容都是这样。为了使事情变得更复杂,当这个软件完成后,它将在服务器上实现,所以如果一切都可以打包成一个单独的库,或者更好的可运行的 jar 文件。

So where is the problem? Well first off it appeared as the user libraries mentioned above are not included on the SVN copy of the project, meaning that my colleagues who wanted to test-drive my project couldn't do so, by just simply acquiring the project from SVN. Now the second phase of the problem unsurfaced when I changed my workstation at work, I wanted to import my project into Eclipse from my backup, but then everything except those user libraries are there. To make things more complicated, when this software is done, it will be implemented on a server so it would be absolutely best if everything could be packed into one single library or a even better a runnable jar file.

以前我曾经建议您查看Maven或Ivy,但是在我们初步了解之后,他们都是从开始,主要是为更复杂的项目。老实说,我完全对我应该如何管理我的依赖感到困惑。有任何想法吗?

I have been previously advised to take a look at Maven, or Ivy, but my initial understanding after checking them both is that they are used from the beginning and mostly for more complicated projects. Honestly I am completely puzzled as to how I am supposed to manage my dependencies. Any ideas?

(对不起,要保留很久,但是我觉得更好的完成和长久的信息不足)

(Sorry for keeping it long, but I figured better complete and long then inadequate information)

编辑:我已经解决了这个问题;这个问题显然源自于eclipse不将所有资源复制到一个地方的简单事实,一些库的安装说明并没有真正提示您如何以最佳方式管理库。

I have managed to sort out the problem; the problem has apparently originated from the simple fact that eclipse doesn't copy all resources to one place, and the installation instructions for some libraries doesn't really warn you about how to manage the libraries in the best way.

感谢大家,谁花时间尝试帮助我。我会及时地看到像Maven和Ivy这样的项目,这绝对是有趣的东西。但是现在我只需要把软件恢复到运行状态,一直用新的东西摔跤太久.. :)

Thanks to everyone, who took their time to try and help me. I will in time look more into projects like Maven and Ivy, it's definitely interesting stuff. However for now I just need to get back to the software into running state, been wrestling with new stuff for too long.. :)

推荐答案

在冒有异端行为的风险之下,我会说Maven并没有在这里过度杀戮。您需要您的SVN项目中的依赖关系,简单。您已将lib文件夹添加到Eclipse中的构建路径,没关系。但是,除非您特别将lib文件夹的内容添加到项目中(如Fred所述),则这些项目将无法提交给SVN - 它们将仅在您的设置的类路径中引用。这对你来说很好,对于任何想要查看你的项目的人来说都是不错的(如你所见)。

At the risk of committing an act of heresy, I'd say Maven and wot-not are overkill here. You need your dependencies in your SVN project, simple as that. You've added your lib folder to your build path in Eclipse, and that's fine. But unless you specifically add the contents of the lib folder to your project (as Fred describes), those items won't be eligible for committing to SVN -- they will simply be referenced in your set-up's classpath. That's good for you, no good for anyone looking to check out your project (as you have found).

我感谢,我们可以无休止的讨论最佳实践,提交第三方图书馆进行版本控制的有效性等等...但我认为大多数人都有工作要做; - )

I appreciate that we could have endless discussions about best practice, the validity of committing third party libraries to version control, and so on and so forth... but I think most people have work to do ;-)

这篇关于在java中处理外部库的正确方法(使用eclipse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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