org.springframework.beans.factory.UnsatisfiedDependencyException 问题

在用mybatis-plus生成代码的时候,生成代码后,springboot项目启动不了,总是这样的错误:

org.springframework.beans.factory.UnsatisfiedDependencyException  XXX No qualifying bean of type ‘com.springboot.modules.myuser.mapper.MyuserMapper‘‘ XXX

看了网上很多的方法,大概有几种:

1》》springboot的启动文件要放在合适的位置,springboot的约定由于配置,例如这样,它会默认去扫描当前包及子包下的文件

如果把启动文件放在了其他地方,又没有配置包扫描,这样会扫描不到文件就会报错。

2》》配置包扫描

上面两种方法:除了上述配置,还需要配置mapper接口的扫描,如:

或者在mapper接口上使用@Mapper注解:

做好这些以后,但发现还是报这样的错,几经排查终于发现,原来是pom.xml中jar包依赖问题:

我依赖的是这种包

      <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus</artifactId>
            <version>3.2.0</version>
        </dependency>

换成整合包就解决问题了:

      <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.0</version>
        </dependency>

原文地址:https://www.cnblogs.com/tdyang/p/12158814.html

时间: 2024-08-30 05:48:41

org.springframework.beans.factory.UnsatisfiedDependencyException 问题的相关文章

启动项目报错:org.springframework.beans.factory.UnsatisfiedDependencyException

dubbo项目: 启动项目报错:(web端) org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.facto

SSM整合报错org.springframework.beans.factory.UnsatisfiedDependencyException

我解决的办法是把.m2仓库所有文件删除,重新maven project就可以了. 但是在做这一步之前,报错如下: ①org.springframework.beans.factory.UnsatisfiedDependencyException ②ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Sta

【实战问题】【14】org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;xxMapper&#39;

问题: SpringBoot启动时报错: Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException:Error creating bean with name 'userDaoMapper' defined in file [E:\WebProject\... 解决方案: pom.xml文件引入了两个Mybatis依赖包.一个是整合SpringBoot的,一个是整合Spring的jar包.两个一

关于Spring中org.springframework.beans.factory.UnsatisfiedDependencyException异常

这个异常是由于在applicationContext.xml中关于bean的autowirte装配类型,在类型byName,byType,constructor三种类型中,可能会出现因无法自动装配而产生题目中的异常. 下面介绍一下关于autowrite的集中装配类型: 1)no:采用自动装配.必须使用ref直接饮用其他Bean<ref bean="JavaBean"/> 2)byName:以属性名区分自动装配.在容器中寻找与JavaBean属性名相同的JavaBean,并假

Spring中org.springframework.beans.factory.UnsatisfiedDependencyException异常

这个异常是由于在applicationContext.xml中关于bean的autowirte装配类型,在类型byName,byType,constructor三种类型中,可能会出现因无法自动装配而产生题目中的异常. 下面介绍一下关于autowrite的集中装配类型: 1)no:采用自动装配.必须使用ref直接饮用其他Bean<ref bean="JavaBean"/> 2)byName:以属性名区分自动装配.在容器中寻找与JavaBean属性名相同的JavaBean,并假

org.springframework.beans.factory.UnsatisfiedDepen

这个异常在网上找了好多办法,什么防火墙啊之类的,最后发现是启动顺序问题,先启动服务提供者,再启动消费者就好了,不然找不到服务就会报这个错误 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'managerItemCatServiceImpl': Unsatisfied dependency expressed through field 'itemCat

springsecurity启动出现org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You must use a 3.0 schema with Spring Security 3.0.

在换了spring-security的jar包以后启动出现org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You must use a 3.0 schema with Spring Security 3.0.Please update your schema declarations to the 3.0.3 schema (spring-securi

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;App&#39; is defined

工具:Eclipse mars 环境:jdk1.8 说明:这是在学习Spring Task时遇到的一个bug,代码如下: 定时任务类: package com.task.test; import java.util.Date; import org.springframework.stereotype.Component; @Component public class App { public void execute1(){ System.out.printf("Task: %s, Curr

异常:Struts:org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find BasicDataSource

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in class path resource [beans.xml]; nested exception is java.lang.ClassNotFoundExcepti