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.StudentService‘ that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type ‘com.example.demo.service.StudentService‘ in your configuration.

Process finished with exit code 0

查了一下,大意是因为我的StudentService没有被SpringBoot的自动装配扫描到,解决办法就是在SpringBootApplication类上加一行注解指定需要被装配的Service包

Like this:

@ComponentScan(basePackages = {"com.example.demo.service"})
public class SpringBootApplication {

原文地址:https://www.cnblogs.com/zilongmao/p/10351312.html

时间: 2024-08-05 10:03:06

Consider defining a bean of type `xxx` in your configuration问题解决问题解决的相关文章

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

启动项目,编译报错:Consider defining a bean of type 'XXX' in your configuration.

在controller层注入ConfigBean,编译器报错: 一开是以为是intellij idea 的告警级别设定的问题,就没有在意,继续启动项目,结果控制台报错:Consider defining a bean of type 'XXX' in your configuration. 错误信息显示找不到这个Bean类. 但是我明明写了啊. 后来经过一番查找,大概有了如下理解:主要问题出在@SpringBootApplication 这个注解上. 点进这个注解,可以看到,此注解功能大概由下面

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 'package' in your configuration [Spring-Boot]

https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-boot Your Applicant class is not scanned it seems. By default all packages starting with the root as the class where you have put @Spri

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】mybatis启动报错:Consider defining a bean of type 'com.newhope.interview.dao.UserMapper' in your configuration.

启动报错: 2018-02-24 22:41:00.442 WARN 2952 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error c

两招解决异常_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

Consider defining a bean of type 'com.lvjing.dao.DeviceStatusMapper' in your configuration.

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.4\lib\idea_rt.jar=55273:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.4\bin" -Dfile.enc

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