简体   繁体   English

在Maven世界中获取Spring(和其他库)

[英]Getting Spring (and other libraries) in a Maven world

I am following an online tutorial, and am stuck trying to get Spring libraries to run things with. 我正在关注一个在线教程,并且我一直试图让Spring库运行。 The instructions are either a little out of date or assume I know how to do things in a Maven world that I do not. 说明要么有点过时,要么假设我知道如何在Maven世界中做我不做的事情。

They give web addresses on the Spring site from which they say I can "download the jars". 他们在Spring网站上提供网址,他们说我可以“下载罐子”。 But you can't download jars from any of them; 但你不能从任何一个下载罐子; evidently what you can do is find pom.xml fragments and use them to download jars. 显然你可以做的是找到pom.xml片段并使用它们来下载jar。 If you know how. 如果你知道怎么做。

For example: the tutorial says: 例如:教程说:

Finally, following is the list of Spring and other libraries to be included in your web application. 最后,以下是要包含在Web应用程序中的Spring和其他库的列表。 You simply drag these files and drop them in WebContent/WEB-INF/lib folder. 您只需将这些文件拖放到WebContent / WEB-INF / lib文件夹中即可。

commons-logging-xyzjar 共享记录,xyzjar

org.springframework.asm-xyzjar org.springframework.asm-xyzjar

org.springframework.beans-xyzjar org.springframework.beans-xyzjar

org.springframework.context-xyzjar org.springframework.context-xyzjar

org.springframework.core-xyzjar org.springframework.core-xyzjar

org.springframework.expression-xyzjar org.springframework.expression-xyzjar

org.springframework.web.servlet-xyzjar org.springframework.web.servlet-xyzjar

org.springframework.web-xyzjar org.springframework.web-xyzjar

spring-web.jar 弹簧web.jar

I love the "simply" here. 我喜欢这里的“简单”。

I have many but not all of these (version 3.2.4). 我有很多但不是全部(版本3.2.4)。 I have googled the library names and used jarfinder for the ones I don't have, but haven't found them all. 我用谷歌搜索了库名,并使用了jarfinder用于我没有的,但还没有找到它们。 It seems to me I'm flailing around a bit, just trying this and that until something works. 在我看来,我有点挣扎,只是尝试这个,直到有效的方式。 I hate that. 我讨厌那个。

I'm hoping someone can give me a set of steps I should follow when faced with this sort of thing, since we're faced with it all the time. 我希望有人可以给我一些我在面对这类事情时应该遵循的步骤,因为我们一直都在面对它。 Do I need to stop my current study of programming and learn Maven inside and out so that I can configure the bloody system so I can program again? 我是否需要停止当前的编程学习并从内到外学习Maven以便我可以配置血腥系统以便我可以再次编程?

Is it a maven project you have? 这是你的maven项目吗?

If so in the pom.xml you just need to place the “pom fragments” in the xml. 如果是这样在pom.xml中你只需要将“pom片段”放在xml中。

ie between the dependencies tags. 即依赖关系标签之间。 For example, 例如,

<dependencies>

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.2</version>
</dependency>

</dependencies>

Once you have done that run maven install. 完成后,运行maven install。 Under Eclipse it is: run as > maven install. 在Eclipse下它是:运行为> maven install。

That will download all the dependences ie jars you have listed into the you local maven repository. 这将下载所有依赖项,即您列出的罐子到您当地的maven存储库。

I think the default is C:\\Users\\yourName\\.m2\\repository 我认为默认值是C:\\ Users \\ yourName \\ .m2 \\ repository

Found most of the needed jar files here: 在这里找到大部分所需的jar文件:

http://www.java2s.com/Code/Jar/CatalogJar.htm http://www.java2s.com/Code/Jar/CatalogJar.htm

while I downloaded commons-logging here: 我在这里下载了commons-logging:

http://mvnrepository.com/artifact/commons-logging/commons-logging/1.2 http://mvnrepository.com/artifact/commons-logging/commons-logging/1.2

My advice is, stop study you program language, Java I guess and learn how to integrate maven dependencies of Spring in your Maven project. 我的建议是,停止学习你的程序语言,Java我猜并学习如何在你的Maven项目中集成Spring的maven依赖项。

http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/ http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/

You cannot start the house from the roof 你无法从屋顶启动房屋

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM