您的位置:首页 > 编程语言 > Java开发

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '***'

2015-03-23 19:22 806 查看

错误如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newsService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:
Could not instantiate bean class [com.zhym.service.NewsService]: Specified class is an interface

Caused by:

org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.zhym.service.NewsService]: Specified class is an interface

错误原因:首先确保service接口的实现类没有错,然后查看applicationContext.xml中对此service的声明,是否把bean中class后的包名中的service实现了写成了service接口。比如service接口名:UserService.java,其实现类为UserServiceImpl.java,而你的bean写成了<bean name="userService" class="com.zyy.service.UserService><!--省略中。。。--></bean>,这里只需把class改为:class="com.zyy.service.UserServiceImpl"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐