Description:
Field helloService in com.example.demo.service.TestController required a bean of type 'com.example.service.HelloService' that could not be found.
Action:
Consider defining a bean of type 'com.example.service.HelloService' in your configuration.
这个问题就是@SpringBootApplication无法生效的问题。因为根据英文的提示是在配置中找不到一个指定自动注入类型的bean,经过多方排查得出结论:
Mapper包是没有被扫描到的,那么我们需要在启动类上面加上注解@MapperScan,这个注解是在org…下面,不是在tk…下面。引入org…包下面的@MapperScan,需要添加依赖:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
更多推荐
关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your conf
发布评论