• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't import Spring classes in SpringSource Tool Suite

 
Ranch Hand
Posts: 66
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just tried to run a "Spring Project" named Hello World on STS 2.9.1 =, but I'm unable to import ApplicationContext(or any other Spring class) into my project. The libraries just aren't there in my project build path. However, when I start with a "Spring Template Project", the libraries come along just fine, but as Maven dependencies. I tried to configure Maven for the Hello World project I started out with, but couldn't proceed on account of utter ignorance of Maven.

Could anybody please tell me what I'm missing?

Thanks,
Debojit
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well nowadays maven is really an essential thing to have under your belt so I would suggest with starting with their getting started documentation. Really everything you need to know is freely available on their website. They even have a free copy of the Maven 2 Oreilly book available for viewing last I knew.
I would start here for familiarizing yourself with maven.
http://maven.apache.org/users/index.html


Now as for setting up your hello world project when you use the template project it puts all your dependencies and such in the POM file for you. If you are unfamiliar with POM files please see the above link.

In STS go to File -> new -> other -> maven -> maven project and click next

When you get the the archetype selection if you are doing a web app then choose maven-archetype-webapp otherwise for a stand alone application the default quickstart that is highlighted is fine.

STS will create the project structure for you. Next I would suggest (after reading the documentation provided in the above link) comparing the POM file generated when you create a spring template project to that of the empty one generated when you created a new maven project. You can mostly just focus on the items contained in the <dependencies> tags. These are the libraries that will be pulled into your classpath that are needed on your projecct build path. For a hello world application you will probably not need all of them start with the basic ones and add what you need if a class is not found.

This blog post is a little dated but is applicable.
http://blog.springsource.org/2009/12/02/obtaining-spring-3-artifacts-with-maven/

 
Debojit Sinha
Ranch Hand
Posts: 66
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply Bill, it gives me something to start out with in my learning. Just asking, , is there no way to get a Spring Project up-and-running without using any of the templates? Or Maven, for that matter.

Thanks,
Debojit
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the way I explained above is done without using the template. You can create a maven project without using STS or even the archetypes if you want as well it is just a time saver and makes life easier.

As for not using maven that is possible as well but there is no longer an uber "spring.jar" so you would have to download all the libs and their transitive dependencies and include them on your projects classpath. There are a lot of those but its possible. If you do go this route (I recommend taking the time to learn maven instead) then downloading the jars from a maven repository (they are actually probably already on your computer in your .m2 directory if you ran a template project) is probably the easiest way to get the jars you need.

Thanks,
 
reply
    Bookmark Topic Watch Topic
  • New Topic