[英]NoClassDefFoundError when init a SpringBoot 2 application in IntelliJ IDEA
I have a SpringBoot 2 application, that when starts I got this error:我有一个 SpringBoot 2 应用程序,启动时出现此错误:
...
Caused by: java.lang.NoClassDefFoundError: Lcom/bonanza/BonanzaHelper;
I went to the service that uses this class:我去了使用这个 class 的服务:
public class BonanzaService {
@Autowired
private BonanzaHelper bonanzaHelper;
I use Ctrl and click on the class and I got this message: Cannot find declaration to go to
but if I use Shift + Ctrl + N
I can find the class in my maven repositoy I use Ctrl and click on the class and I got this message: Cannot find declaration to go to
but if I use Shift + Ctrl + N
I can find the class in my maven repositoy
the class is imported in a parent
group in the pom.xml
class 被导入到pom.xml
的parent
组中
it may look like one of the following: 1. You may have two dependencies in the pom that point to a different version of the artifact with different locations它可能看起来像以下之一: 1. 您可能在 pom 中有两个依赖项,它们指向具有不同位置的工件的不同版本
The class is not declared as Bean, so you can autowired it, you can do it in the @configuration file: class 没有声明为 Bean,所以你可以自动装配它,你可以在 @configuration 文件中做到:
@Bean public ObjectMapper bonanzaHelper() { return new BonanzaHelper();} @Bean public ObjectMapper bonanzaHelper() { return new BonanzaHelper();}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.