SpringBoot: Field xxx in xxx required a bean of type 'xxx' that could not be found.

SpringBoot自动注入报了如下错误

原因是我这个模块依赖另一个模块里面的被Spring管理的类,但是不在同一包下面,

并且启动类不是在根包下面,所以就导致了springboot启动的时候扫描不到,也就管理不到这个类,也就无法找到,

解决方案:

  1.SpringBoot启动类放到包的跟包下面比如每个包都包含 cn.arebirth.xx  那就放在cn.arbeirth下面

  2.设置SpringBoot扫描的包路径即可解决

SpringBoot: Field xxx in xxx required a bean of type 'xxx' that could not be found.

原文地址:https://www.cnblogs.com/arebirth/p/springbootautowiredbasepackagepatherror.html

时间: 2024-08-11 14:24:37

SpringBoot: Field xxx in xxx required a bean of type 'xxx' that could not be found.的相关文章

运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.

运行springboot项目报错: *************************** APPLICATION FAILED TO START *************************** Description: Field userMapper in com.whohim.springboot.service.impl.UserServiceImpl required a bean of type 'com.whohim.springboot.dao.UserMapper' t

springboot 报错Field XXX required a bean of type XXX that could not be found.

报错原因: MyBatis是第三方组件,spring并不会自动管理MyBatis相关对象的生命周期,因此需要手动配置,将MyBatis相关对象交给spring容器来管理. 解决方式: 在启动类中增加注解@MapperScan("cn.lxy.repository") 原文地址:https://www.cnblogs.com/think-world/p/12300546.html

Field XXX in XXXX required a bean of type XXXX that could not be found

这个报错的意思是:没有找到相应的bean. 出现这个情况我遇到了两种: 1.spring没有扫描到相应的bean. 原因是springboot项目启动,只有@SpringBootApplication 所在的包被被扫描,如果有其他需要扫描的包,需要显式写明: @SpringBootApplication@MapperScan({"cn.jhxcom.web.demo.mapper",    "com.baomidou.mybatisplus.samples.quickstar

springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.

一.前言: 使用springboot自动注入的方式搭建好了工程,结果启动的时候报错了!!!,错误如下图: Description: Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type 'com.xxx.xxx.dao.UserEntityMapper' that could not be found. Action: Consider defining a bean of type '

Consider defining a bean of type `xxx` in your configuration问题解决问题解决

在使用SpringBoot装配mybatis时出现了异常 *************************** APPLICATION FAILED TO START *************************** Description: Field studentService in com.example.demo.action.StudentController required a bean of type 'com.example.demo.service.StudentS

org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'xxx 'available

搭了一个简单的SSM项目,启动报错: org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.xxx.ssmdemo.service.IUserService' available: expected at least 1 bean which qualifies as autowire candidate.Dependency annotations: {@o

spring注入时报错::No qualifying bean of type 'xxx.xxMapper'

做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Autowired, 结果,junit一启动,就报错误:Java.lang.illegalStateException:Failed to load ApplicationContext 具体是在 创建bean的时候报:No qualifying bean of type 'xxx.xxMapper' ab

spring boot注入error,Consider defining a bean of type 'xxx' in your configuration问题解决方案

经常出现这问题一定是非spring生态圈的@标签 没被spring引入,如mybatis等 因为在默认情况下只能扫描与控制器在同一个包下以及其子包下的@Component注解,以及能将指定注解的类自动注册为Bean的@[email protected]和@ Repository 那个这个时候就需要@ComponentScan或者@MapperScan了 要是xml配置注入有这问题,麻烦一遍一遍看xml文件的配置,绝对是哪里没写匹配. spring boot注入error,Consider def

两招解决异常_Cannot find any information on property 'XXX' in a bean of type 'XXX'的问题

第一招 在进行Java Web项目开发的时候,我碰到过下面这个异常: Cannot find any information on property 'XXX' in a bean of type 'XXX' 如图: 这是javaBean中: 这是显示结果的jsp页面中: 解决方法是: 将javaBean中setClassRanking_she方法改为setClassranking_she,保持存在一个大写字母是安全的. 第二招 on property 'XXX' in a bean of ty