如何在Eclipse中加载Spring相关的jar? [英] How should you load Spring related jar in Eclipse?

查看:181
本文介绍了如何在Eclipse中加载Spring相关的jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想从示例中运行代码,所以我复制了代码。



我安装了Spring STS套件,并有一个测试弹簧项目。它似乎不包含spring的jar隐式,所以我需要配置构建路径,并包括和jar逐个。
和jar在一些奇怪的位置(我认为它们是由Spring STS安装的,虽然我不知道它是否包括Spring本身)。



弹簧核心取决于从apache的常见日志记录:



我需要去apache常见的日志记录站点下载jar并将其放在项目的lib文件夹中,然后将其设置在构建路径中。



整个过程是无法忍受的。如果春天有20罐罐子怎么办?还有其他方法吗?



感谢所有。

解决方案

为了缓解获得依赖性的痛苦,强烈建议您使用Maven。



您需要开始的所有内容如下:


  1. 结帐 我有一个'Helloworld'Spring + Maven项目(专门用于使用 Spring In Action ,我可以添加)设置在Git Hub,这应该让你开始没有任何麻烦。




    • 如果您熟悉GIT,则fork 存储库否则


    • 将整个项目下载为zip / tarball来自 此处


      此项目也可以作为Spring应用程序的起点。阅读更多关于如何使用Maven获取Spring依赖关系 here





一旦你这样做,项目目录中的一个 mvn clean install 就是你需要获取所有必需的依赖项,没有手动笨蛋要拿罐子,把它们放在classpath等等等等。


I new with spring and is following the example from "Spring in Action 3rd Edition".

I want to run the code from the example, so I copied the code.

I install Spring STS suite and have a test spring project. It seems it doesn't include spring's jar implicitly so I need to configure the build path and include and jar one by one. And jar is in some strange location too (I think they are installed by Spring STS, although I have no idea whether it include Spring itself).

And the spring core depends on common logging from apache:

And I need to go to apache common logging site to download the jar and put it in the lib folder of the project, then set it in the build path.

The whole process is unbearable. What if spring got 20 jars? Is there other way to do this?

Thanks all.

解决方案

To ease the pain of getting the dependencies, it's highly recommended that you use Maven.

All you need to get started is the following :

  1. Checkout this 5 minute start for Apache Maven.

  2. I have a 'Helloworld' Spring + Maven project (specifically to work with Spring In Action, I might add) setup on Git Hub which should get you started without any hassle.

    • If you are familiar with GIT then fork this repository otherwise,

    • Download the whole project as a zip/tarball from here.

      This project can also be used as the starting point for a Spring app. Read more about how to get the Spring dependencies using Maven here.


Once you do that a mvn clean install inside the project directory is all you need to get all the required dependencies and there is no manual mucking about to get the jars, put them in the classpath and so on and so forth.

这篇关于如何在Eclipse中加载Spring相关的jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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