Field userMapper in com.jiutou.controller.UserController required a bean of type ‘com.jiutou.mapper.UserMapper’ that could not be found.问题
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userMapper in com.jiutou.controller.UserController required a bean of type 'com.xxx.mapper.UserMapper' 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.xxx.mapper.UserMapper' in your configuration.
Process finished with exit code 0
和Error creating bean with name ‘userController’: Unsatisfied dependency expressed through field ‘userMapper’;问题
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file 。。。。。
我的解决方案
忘了导 mybatis-spring-boot-starter包,在pom里加上
<!-- mybatis-spring-boot-starter -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>