Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:

我的项目是maven项目,所有公网上有的jar包都是通过pom.xml配置的,由于需要用到公司内部的jar,于是我将xxxx.jar文件放在lib目录下,并且build path - > add ...,而且在Referenced Libraries可以看到已经完成了jar包的导入,而且在写码(自动编译)也能正常import里面的package,但是当我启动项目的时候就报错了:

2019-06-21 10:10:15,640 [ERROR] org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apolloController' defined in file [F:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ssm-scaffold-master\WEB-INF\classes\com\xxxxx\apollo\controller\ApolloController.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/xxx/xxx/sdk/config/ArtemisXXConfig

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(.....

 

明明就已经正常导入了jar包,且正确import package,为什么启动的时候报错了呢?于是网上搜了搜找到了解决的方法。

 

解决方法:

项目-->属性-->Deployement Assembly 

Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:_第1张图片

这里显示的就是服务正常运行时所需要的资源,发现这里并没有xxx.jar的相关信息。于是点击 “Add”按钮,弹出如下页面:

Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:_第2张图片

选择Java Build Path Entries:

Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:_第3张图片

选择jar包,然后Finish.即可!如图:

Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:_第4张图片

 

然后启动项目,启动成功!

你可能感兴趣的:(java,Eclipse)