try to compile the simplest Spring program:
Main.java
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
//
public class Main {
private String who = null;
public static void main(String[] args) {
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld hw1 = (HelloWorld)factory.getBean("hello");//map.get("hello")
System.out.println(hw1.getInfo());
System.out.println(hw1);
}
}
Command Line:
$javac -cp /path/of/spring-beans.jar:/path/of/spring-context-support.jar Main.jar
complete:
javac -cp /Users/apple/Desktop/springt/sp/spring-framework-5.0.5.RELEASE/libs/spring-beans-5.0.5.RELEASE.jar:/Users/apple/Desktop/springt/sp/spring-framework-5.0.5.RELEASE/libs/spring-context-support-5.0.5.RELEASE.jar Main.java
error report:
Main.java:3: error: package org.springframework.context.support does not exist
import org.springframework.context.support.ClassPathXmlApplicationContext;
^
Main.java:12: error: cannot find symbol
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
at first I thought there was something wrong with me, but the unzipped jar package found that
org.springframework.beans.factory.BeanFactory
is normal, but
spring-context-support-5.0.5.RELEASE
there is no context.support
directory:
$ tree -L 3
.
META-INF
MANIFEST.MF
license.txt
notice.txt
org
springframework
cache
mail
scheduling
ui
7 directories, 3 files
$ pwd
/Users/apple/Desktop/springt/sp/spring-framework-5.0.5.RELEASE/libs/spring-context-support-5.0.5.RELEASE
Why is this happening?
I re-downloaded several earlier versions of the Spring jar package, and I also don"t have a corresponding directory. What"s wrong with me?