Could not autowire.No beans of ‘userMapper‘ type found.

这里并没有错误,但是IDEA报红

Could not autowire.No beans of ‘userMapper‘ type found._第1张图片

package com.example.demo.mapper;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)  // 启动这个单元测试类
public class UserMapperTest {
    @Autowired
    UserMapper userMapper;

    public void insert() {

    }
}

点击File>Settings>Inspections>Spring>Spring Core>Core>Autowiring for Bean Class>Severity:No highlighting,only fix

最后点击ok

Could not autowire.No beans of ‘userMapper‘ type found._第2张图片

解决

你可能感兴趣的:(spring,boot,java,spring,boot)