编码:
import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Hello {
private String s;
public Hello(String str){
s = str;
}
public void sayHi(){
System.out.println(s);
}
public static void main(String []args){
ClassPathXmlApplicationContext ac = null;//
try {
ac = new ClassPathXmlApplicationContext(new String[] {"config.xml"});
Hello h = (Hello) ac.getBean("hello");//
h.sayHi();
} catch (BeansException e) {
e.printStackTrace();
}
}
}
IntelliJ Idea 标记为红色的问题:
这很奇怪,因为 BeansException 从 Throwable 继承: http ://static.springsource.org/spring/docs/2.0.2/api/org/springframework/beans/BeansException.html 是 什么原因以及如何解决?