org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.springboot.LibrarySystem.mapper.UserMapperTest': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.sb.LibrarySystem.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
还是从这个Test类下手
本来我的类是这样的:
1 2 3 4 5
@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class UserMapperTest {
}
修改后就是这样,和我的启动类的类名是一致的:
1 2 3
@RunWith(SpringRunner.class) @SpringBootTest(classes = App.class) public class UserMapperTest {