• 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

Spring classes not resolved even with libs added

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was try to set up the basic spring environment. I have download spring distribution 3.1.1 add all the below jars to the eclipse build path with org.springframework.context-sources-3.1.1.RELEASE.jar which contains ApplicationContext and ClassPathXmlApplicationContext classes.

But still eclipse shows the build error,
"Multiple markers at this line
- ApplicationContext cannot be resolved to a type
- ClassPathXmlApplicationContext cannot be resolved "



What i am missing here please?
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a build tool like maven or gradle.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Gorder wrote:Use a build tool like maven or gradle.



thank you. but what i did manually was what maven would do by downloading the jars specify in pom.xml and add them to the build path.
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many jars you will need to add, not just spring-context. You will spend a great deal of time downloading all of these and getting it to work. Also when you decide to upgrade to a newer version of Spring you are going to have to go through all of that work again.

If you want to do this manually, its your choice but its a wasted effort and not recommended.

You said


You need the classes not the sources. Spring assumes you are using a build tool like maven and so you cannot download them from the website. You can download the JAR from the maven repository.

http://mvnrepository.com/artifact/org.springframework/spring-context/3.1.2.RELEASE
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Gorder wrote:
org.springframework.context-sources-3.1.1.RELEASE.jar [/code]

You need the classes not the sources. Spring assumes you are using a build tool like maven and so you cannot download them from the website. You can download the JAR from the maven repository.



Actually is it mandatory that dependent libs should be in .class? Even if those are in .java, compiler will make .class files in the build folder know. Also i didnt add only context jar but add all jars which comes with spring distribution.

You are correct on adding each jar would be a time consuming.
But why shouldn't the spring distribution comes with .class version of all jars needed as it comes with sources with all jars needed. In that case we just need to point the all jars coming with spring distribution to out build path know.
 
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

Actually is it mandatory that dependent libs should be in .class? Even if those are in .java, compiler will make .class files in the build folder know.



If you want it to run yes. The source jar is useful if you want to be able to be able to open a class in your IDE and view the source. The sources are also needed to build the project if you wanted to make changes to the framework classes. If you wanted to do that you would follow the instructions here:
http://blog.springsource.org/2009/03/03/building-spring-3/

After building Spring from the source contained in that jar you would end up with exactly the same jar I had linked to in my last post.

Simply including a jar containing source files does not mean your IDE is going to automatically compile them for you. Think of a jar file as similar to a zip.


But why shouldn't the spring distribution comes with .class version of all jars needed as it comes with sources with all jars needed.



I have been using Maven so truthfully had not downloaded it from their website. I did so now and peeked in it. in the src folder you have all the source jars. In the dist folder you have all the compiled jars. Use the jars in the dist folder.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Gorder wrote:

I have been using Maven so truthfully had not downloaded it from their website. I did so now and peeked in it. in the src folder you have all the source jars. In the dist folder you have all the compiled jars. Use the jars in the dist folder.



Thank you. i have missed the dist forlder. Adding jars in dist forlder solved the problem. I haven't use maven before. Im going to try maven2eclipse to build the project with maven.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic