aspose file tools*
The moose likes Spring and the fly likes Spring classes not resolved even with libs added Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring classes not resolved even with libs added" Watch "Spring classes not resolved even with libs added" New topic
Author

Spring classes not resolved even with libs added

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
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?
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

Use a build tool like maven or gradle.


[How To Ask Questions][Read before you PM me]
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
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

Joined: Mar 07, 2010
Posts: 1666
    
    7

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

Joined: Jun 11, 2007
Posts: 327
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

Joined: Mar 07, 2010
Posts: 1666
    
    7

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

Joined: Jun 11, 2007
Posts: 327
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring classes not resolved even with libs added