简体   繁体   中英

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. 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.

They give web addresses on the Spring site from which they say I can "download the jars". 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. 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. You simply drag these files and drop them in WebContent/WEB-INF/lib folder.

commons-logging-xyzjar

org.springframework.asm-xyzjar

org.springframework.beans-xyzjar

org.springframework.context-xyzjar

org.springframework.core-xyzjar

org.springframework.expression-xyzjar

org.springframework.web.servlet-xyzjar

org.springframework.web-xyzjar

spring-web.jar

I love the "simply" here.

I have many but not all of these (version 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. 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?

Is it a maven project you have?

If so in the pom.xml you just need to place the “pom fragments” in the 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. Under Eclipse it is: run as > maven install.

That will download all the dependences ie jars you have listed into the you local maven repository.

I think the default is C:\\Users\\yourName\\.m2\\repository

Found most of the needed jar files here:

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

while I downloaded commons-logging here:

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.

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

You cannot start the house from the roof

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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