1

I started learning spring framework recently. I added all the spring libraries to the classpath of my project. But I am getting a import org not found error.

package com.springlearnging.springdemo;

//Getting error at this import
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloSpringApp {

    public static void main(String[] args) {
        //load spring config file
        ClassPathXmlApplicationContext context = new  ClassPathXmlApplicationContext("applicationContext.xml");
        //retrieve bean from spring container

        //call methods

        //close context

    }

}
Monzurul Shimul
  • 8,132
  • 2
  • 28
  • 42
prasadmsvs
  • 1,621
  • 4
  • 18
  • 31

2 Answers2

0

If you are leaning the Spring Framework, it will be much easier for you to start with Spring Boot and the Spring Initializr. The Spring Initializr allows you to generate a correctly configured initial project.

Consider also using the Spring Tool Suite which is customised Eclipse made for Spring development.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
  • I understand that spring boot gives a opinionated project structure. I just want to understand why the above is not working. In the udemy tutorial I am following they were able to do this. – prasadmsvs Sep 09 '18 at 13:58
  • If you are following a tutorial, you should mention it explicitly in your question and provide a link to it. – Ortomala Lokni Sep 09 '18 at 14:07
  • It's a udemy course. It's a paid link. That's why I didn't mention. I just wanted to understand if adding the all the spring jars to classpath is enough or not – prasadmsvs Sep 09 '18 at 16:13
  • Ok, I understand. Can you edit your question and explain how do you build and run the application and add the exact error message. – Ortomala Lokni Sep 09 '18 at 17:44
0

The issue is with java version. Compiling with JavaSE-1.8 solved the issue

prasadmsvs
  • 1,621
  • 4
  • 18
  • 31