发表于: 2020-04-26 00:01:18

3 1159


今天完成的事情:

上传spring mybatis整合项目到服务器

验证项目&开始打包:(mvn clean package)

打包完成:


执行插入 10000 条数据测试:mvn test -Dtest=cn.mogeek.dao.testInsert

update 测试:(mvn test -Dtest=cn.mogeek.dao.testUpdate)

select 测试查找刚刚 update 的数据:(mvn test -Dtest=cn.mogeek.dao.testQuery)

delect 测试:(mvn test -Dtest=cn.mogeek.dao.testDelete)


编写 main:

start.java

package cn.mogeek;


import org.springframework.context.ApplicationContext;
import java.util.List;
import cn.mogeek.domain.Disciple;
import cn.mogeek.dao.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;

class Test{
public void testInsert(DiscipleDao discipleDao) throws Exception{
Disciple disciple = new Disciple();
disciple.setQq(100000);
disciple.setObject("无限奥义循环");
disciple.setName("奇异博士-NO:");
disciple.setComefrom("英国");
disciple.setDaily_report("https://baike.baidu.com/item/%E5%A5%87%E5%BC%82%E5%8D%9A%E5%A3%AB/2492942");
disciple.setBrother("古一法师");
disciple.setAims("打败多玛姆");
disciple.setGraduated_school("格林威治村");

Disciple temp = (Disciple)disciple.clone();
for (int i = 10000; i > 0; i --){
temp.setQq(disciple.getQq() + i);
temp.setName(disciple.getName() + String.valueOf(i));
discipleDao.insert(temp);
}

}

public void testUpdate(DiscipleDao discipleDao) throws Exception {
Disciple disciple = new Disciple();
disciple.setId(1013);
disciple.setQq(666666);
disciple.setName("暗灭");
System.out.println(discipleDao.update(disciple));
}


public void testQuery(DiscipleDao discipleDao) throws Exception{
Disciple disciple = new Disciple();
disciple.setName("暗灭");
List<Disciple> discipleList = discipleDao.query(disciple);
for (Disciple singleOne: discipleList){
System.out.println(singleOne);
}
System.out.println("共查询到结果:" + discipleList.size());
}

public void testDelete(DiscipleDao discipleDao) throws Exception{
System.out.println(discipleDao.delete(1013));
}
}

public class start{


public static void main(String[] args){
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
DiscipleDao discipleDao = (DiscipleDao)applicationContext.getBean("discipleDao");

try {
Test test = new Test();
test.testInsert(discipleDao);
test.testUpdate(discipleDao);
test.testQuery(discipleDao);
test.testDelete(discipleDao);
}catch (Exception e){
System.out.println(e);
}

}
}
}

执行main(mvn clean compile exec:java -Dexec.mainClass="cn.mogeek.start"

(但是最后结果好像有点问题)

好像是线程出了什么错误,盲猜是连接池方面的知识欠缺。


明天的计划:

学习连接池。


收获:

今天学习了 java 注解,之前使用 @After @Test 的时候完全是照猫画虎,今天看了之后理解了注解的原理。

在做测试的时候想要复制类,学习了 深克隆 与 浅克隆。

学习了 maven 的基本命令行操作。


返回列表 返回列表
评论

    分享到