AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
cn.li.crud.bean controller dao service test //SpringTest ~~~ /** * * 使用spring的单元测试 * 1.依赖添加进来 * 2.使用spring单元测试,可以自动从容器中注入对象(模拟请求的提交) * @ContextConfiguration 主要作用是用来指定spring配置文件的位置 * @RunWith 表示如果说方法被@Test修饰 那么使用spring提供的单元测试类 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:applicationContext.xml"}) public class SpringTest { @Autowired private DepartmentMapper departmentMapper; @Autowired private EmployeeMapper employeeMapper; @Autowired private SqlSession sqlSession; @Test public void test1(){ // Department dept=new Department(8,"事业部"); // departmentMapper.insert(dept); //批量添加 // for (int i = 0; i < 1000; i++) { // String uuid=UUID.randomUUID().toString().substring(0, 5); // Employee emp=new Employee(null,uuid,"W",uuid+"@qq.com",8); // EmployeeMapper mapper = sqlSession.getMapper(EmployeeMapper.class); // mapper.insert(emp); // } // System.out.println("插入完成"); List<Employee> emps = employeeMapper.selectWithDept(); for (Employee employee : emps) { System.out.println(employee); } } } ~~~