首先加入pom

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>`在这里插入代码片`

加入注解,我之前这两个pom没加全,只加了一个,搞半天RunWith都不出来

@RunWith(SpringRunner.class)
@SpringBootTest
public class test01 {
//自动注入,让spring去生成JavaBean
 @Autowired(required = false)
    private InfoMapper infoMapper;

    @Test
    public void test01(){
        User user =new User();
        user.setId(2);
        user.setUsername("www");
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username","www");
        wrapper.eq("password","123456");
        User user1= userMapper.selectOne(new QueryWrapper<>(user));
        System.out.println(userMapper.selectById(1));
        System.out.println(user1);
        System.out.println(userMapper.selectList(null));
    }

}
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐