Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/annotation/SqlParser at

xumeng2022 / 2024-10-16 / 原文

问题描述

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysAlgorithmController': Unsatisfied dependency expressed through field 'algorithmService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysAlgorithmServiceImpl': Unsatisfied dependency expressed through field 'algorithmMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysAlgorithmMapper' defined in file [D:\DevProject\jjycpyf\jyy-cpyf-app-main\target\classes\com\sgai\jyy\algorithm\mapper\SysAlgorithmMapper.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/annotation/SqlParser
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
at com.sgai.IiotApplication.main(IiotApplication.java:24)

解决方案

mybatis-plus版本问题,我用的3.4.1,系统要求的是3.5.3

感悟

遇到问题不要慌,我刚入门,一个bug要解决好长时间,经验多了就会变得从容,不过这个报错太笼统了,网上找不到解决方案,看它的提示显示的是sql的问题,我就要推测是不是版本用的不一样,我是在别人开发的代码平台上联合开发,最后问前辈,帮我定位一下是不是mybatis-plus版本用的不对。
整个问题出现的情况是,我没写代码之前,跑一个别人写好的其他模块的代码,没问题,我写了我这个模块的代码,报错的是别人模块代码sql的问题。