1. 程式人生 > >Spring 配置bean報錯 java.lang.ExceptionInInitializerError

Spring 配置bean報錯 java.lang.ExceptionInInitializerError


報錯資訊

java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bs' defined in class path resource [tx.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cn.com.day04.BookShopService]: Specified class is an interface
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cn.com.day04.BookShopService]: Specified class is an interface


在測試類中需要用到的類,在xml檔案中配置錯誤

錯誤的原因:

1、類的class位置不對;

2、id的名稱不一致