Issue
I learning Java Spring Framework by listening to the "Spring & Hibernate for Beginners" udemy course. I struggled while trying to import org.springframework.context.support.ClassPathXmlApplicationContext;
Eclipse shows me the error: ClassPathXmlApplicationContext cannot be resolved
The author of the course to which I'm listening is still not involving Maven (and pom.xml) because he is concentrating on "pure" Java and Spring in his course, so please don't direct me to use Maven for organizing the project.
I added all jars from spring-framework-5.0.2.RELEASE-dist to my projects buildpath.
The funny thing is that when i do CTRL+Shift+O Eclipse automatically imports the org.springframework.context.support.ClassPathXmlApplicationContext package, but it shows error in import line (red line under org) and shows an error in my main function on the line where I try to use context as:
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Please help.
Solution
I just want to share that ะจ have found a solution to my problem. My execution environment JRE was set to be JAVA SE 10. After I change it to be JAVA SE 1.8 everything started working, and no errors are showing now.
I do it like this:
- Right click on your project, then open Properties
- Java build path
- Click on Add Library
- Choose JRE system library
- Click on environments and choose JAVA SE 1.8
- After that, I removed JAVA SE 10 from my build path and everything becomes right.
Answered By - nvkvc