org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.example.springbootmybatis.SpringBootMybatisApplicationTests’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.example.springbootmybatis.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
主要就是开头一句话,bean出问题了
UnsatisfiedDependencyException: Error creating bean with name ‘com.example.springbootmybatis.SpringBootMybatisApplicationTests’: Unsatisfied dependency expressed through field 'userMapper’;
原因
在usermapper里面没有用@mapper注解
我一开始只用了@respository,加上@mapper就好了。