今天写了个SSH2的小程序,因为程序小,包名就直接用了org.*。
1.<context:component-scan base-package="org.*"/>导致内存溢出
beans.xml中使用 <context:component-scan base-package="org.*"/>进行自动扫描。
结果程序启动时在加载beans.xml时停顿一会,就报了
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.OutOfMemoryError: Java heap space
最后将包名换了,不让直接扫描org.*下的包了。
2.<context:component-scan/>的作用
我的理解就是,Spring 会自动去扫描base-package 属性中指定包中的类,查找里面的annoatation。