Spring-mybatis-入门程序
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.inmind;
|
||||
|
||||
import com.inmind.mapper.UserMapper;
|
||||
import com.inmind.pojo.User;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringbootMybatisQuickstartApplicationTests {
|
||||
|
||||
@Autowired//直接从IOC容器中获取UserMapper类型的对象
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
//使用mybatis框架查询所有用户的数据
|
||||
List<User> list = userMapper.list();
|
||||
list.stream().forEach(user -> {
|
||||
System.out.println(user);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user