idea中springboot无法自动装配Could not autowire. No beans of ‘UserMapper‘ type found

方案一

在自动转配的注解后面添加(required=false)

    
    @Autowired(required=false)
    public UserMapper userMapper;

idea中springboot无法自动装配Could not autowire. No beans of ‘UserMapper‘ type found

当我们在使用@Autowired注解的时候,默认required=true,表示注入的时候bean必须存在,否则注入失败。
方案二

idea中springboot无法自动装配Could not autowire. No beans of ‘UserMapper‘ type found