Spring in Action - Chapter 1

Spring in Action - Chapter 1
1、HelloApp
书上是:
BeanFactory factory = new XmlBeanFactory(new FileInputStream("hello.xml"));
应该是:
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("hello.xml"));

2、KnightApp
在实现了XML中Minstrel的interceptor后,
需要把
KnightOfTheRoundTable knight = (KnightOfTheRoundTable) factory.getBean("knight");
改成:
Knight knight = (Knight) factory.getBean("knight");
否则会报:
Exception in thread "main" java.lang.ClassCastException: $Proxy0

你可能感兴趣的:(Spring in Action - Chapter 1)