如果配置spring时出现 It is indirectly referenced from required .class files

运行代码是出现如下错误信息:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files
    The constructor ClassPathXmlApplicationContext(String) refers to the missing type BeansException
    The method getBean(String, Class<People>) is undefined for the type ApplicationContext

出错原因:是找不到相应的依赖包,所以会出现:

It is indirectly referenced from required .class files

解决办法:
在spring文件夹下spring-framework-4.1.6.RELEASE-dist\spring-framework-4.1.6.RELEASE\libs下找到spring-beans-4.1.6.RELEASE.jar包并导入就可以了
posted @ 2019-05-23 20:24  hzh666  阅读(458)  评论(0编辑  收藏  举报