i am new to Spring and went out to learn Spring tutorials from here using Eclipse.
But, in Eclipse i cannot import these two libraries
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
I even downloaded the Spring source files from the Spring site, included it in the system library, added it in my project and also in the lib folder of my project but no in vain.
Can you help me out to know where exactly is the problem and suggest me some good Spring tutorials sites please.
Thank you all
EDIT
Here is the exception
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ApplicationContext cannot be resolved to a type
ClassPathApplicationContext cannot be resolved to a type
at com.test.App.main(App.java:12)
Finally got it. My mistake, i was using jars from the src folder and making it as a user library but the correct way is to use the jars from the dist folder.
Thank you guys for your answers. :)
Based on comments:
Your jars haven't been included in the classpath. Hence you're getting the compilation errors.
This will include all jars inside the lib folder to your classpath and you won't get any compilation errors.
By the way. These classes are part of spring-context jar so make sure that's in the lib folder.
Update dependency in your pom.xml file, as below:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.5</version>
</dependency>
Add the dependency of spring-context. For gradle project. implementation group: 'org.springframework', name: 'spring-context', version: '5.3.6'
this solved the issue for me.
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.