简体   繁体   English

在 IntelliJ IDEA 中初始化 SpringBoot 2 应用程序时出现 NoClassDefFoundError

[英]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.xmlparent组中

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 中有两个依赖项,它们指向具有不同位置的工件的不同版本

  1. 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.

相关问题 IntelliJ IDEA NoClassDefFoundError - AbstractExpectedPatterns - IntelliJ IDEA NoClassDefFoundError - AbstractExpectedPatterns 使用 Intellij IDEA 开发 Springboot 应用程序 - Ultimate Version 2018 - Developing Springboot Application using Intellij IDEA - Ultimate Version 2018 从intellij启动springboot项目时出现“引起:java.lang.NoClassDefFoundError:javax / servlet / http / HttpServlet” - getting a “Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet” when starting springboot project from intellij 如何从Java IDE为专业开发人员(IntelliJ IDEA)运行SpringBoot应用程序 - How to run a SpringBoot application from Java IDE for Professional Developers (IntelliJ IDEA) 在Intellij IDEA中导出可运行jar时,如何修复java.lang.NoClassDefFoundError? - How to fix java.lang.NoClassDefFoundError when exporting runnable jar in Intellij IDEA? 打包库时,IntelliJ IDEA中的Java代理(工具API)java.lang.NoClassDefFoundError - Java Agent (Instrumentation API) java.lang.NoClassDefFoundError in IntelliJ IDEA When Packaging Libraries java.lang.NoClassDefFoundError: 在 Intellij Idea 中构建 jar 时的 io/reactivex/subjects/Subject (gradle + JavaFX 11) - java.lang.NoClassDefFoundError: io/reactivex/subjects/Subject when building jar in Intellij Idea (gradle + JavaFX 11) Intellij 想法 NoClassDefFoundError: com/intellij/util/messages/Topic - Intellij Idea NoClassDefFoundError: com/intellij/util/messages/Topic 通过Intellij IDEA运行Web应用程序时,编译后的Webapp在哪里? - Where is the compiled webapp when running a web application through Intellij IDEA? Intellij idea Debug:应用程序正在运行 - Intellij idea Debug: the application is running
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM