Search code examples
eclipsespringeclipse-pluginspring-ide

Why are the Spring Libraries mising in my Eclipse project?


I am just beginning to learn Spring. I have already read about the Spring IDE (Eclipse plug-in) and STS. So I decided to install the Spring IDE with Eclipse.

Right now I'm going through the tutorials for (DI). I have created a class which it will be injected in another. I also have created the xml configuration, however I can not create the bean which uses the Spring Inversion of Control because I eclipse does not find the imported libraries for Spring itself. For example:

import org.springframework.context.ApplicationContext; import org.springframework.context.support. ClassPathXmlApplicationContext

Do I need import the external jars or install the Spring Framework? If so, why? I'm not understanding this problem because if I install the eclipse plugin, wouldn't I have the needed libraries in there?

I know this is a basic question but I have not found a clear answer.


Solution

  • You don't mention what version of Eclipse or STS you are using. You could just create a java project with Spring added via a pom.xml or you could just add the libraries to a java project.

    I assume you are getting a file import error in Eclipse, correct?

    Just because you have the Spring plugin, it doesn't load up the libraries for you perse. If you are creating a regular java project for example, no Spring libraries are loaded. You have to set the libraries up using some configuration, like the ones mentioned or even adding the libraries from the libraries tab under the build path on the project.

    With all due respect for your endeavors, I would focus on some basic eclipse web projects first and then move up to Spring. You are getting bogged down with the basics of project setups here.

    However, if you want to continue with Spring at this point, here are some tutorials that should help you.

    Basically, to answer your question, the plugin doesn't set up all the Spring libraries for you. I assume that is because with Spring, you configure only the components you need for your project. For example, if you are not using Spring AOP, then you don't add in the libraries for it.

    Here is a basic list of features for the Eclipse Indigo STS plugin. that explains what it can do for you.