发表于: 2017-12-31 22:29:24

1 474


一.刚才,我完全凭借自己的努力,修改了一个bug(可以称之为bug吗?)就是昨晚不能查询的测试类,可以查询了。

1. StudentDao类里面,以前的时候是:

public interface StudentDao {

public Student getStudent(Student student);  

public void addStudent(Student student);

public void updateStudent(Student student);

public void deleteStudent(int StudentId);

运行测试类的时候报错,说找不到get,然后我就把上面的第二句改成了:public void getStudentStudent student);

 

2.如图所示:

 public void getStudentTest() {
    ApplicationContext ctx = null;
    ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
    StudentDao studentDao = (StudentDao) ctx.getBean("StudentDao");
    Student student = new Student();


    student.setStudentName("常雷雷");
    student.setStudentPassword("12345");
    System.out.println(student.toString());
}

 

绿色字体是从public void addStudentTest(){}下面复制过来的。昨天貌似还有个等号,也被我删了。最后一句原文是System.out.println(studentDao.getStudent(student).toString()):,字体爆红,我用ALTenter键,改好了,至于为什么能改好,不明白原因。

 

二.修改数据也是无法运行报错的。原文是这样的:

    //修改数据
    @Test
    public void insertStudentTest(){
   student.setId(2);
   student.setStudentPassword("802");
    studentDao.updateStudent(student);
    System.out.println("修改成功");
}

1. insertStudentTest改为updateStudentTest(){}

2. 把前面那一句话ApplicationContext ctx = null;

    ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");

    StudentDao studentDao = (StudentDao) ctx.getBean("StudentDao");

    Student student = new Student();粘贴到{后面。

3. 报错说邮箱不能为空,所以程序语言加了个邮箱。student.setStudentEmail("hanyaohe@163.com");

4. 最后原文变成这样:

    //修改数据
    @Test
    public void updateStudentTest(){
        ApplicationContext ctx = null;
        ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        StudentDao studentDao = (StudentDao) ctx.getBean("StudentDao");
        Student student = new Student();


   student.setId(2);
   student.setStudentPassword("802");
   student.setStudentEmail("hanyaohe@163.com");
    studentDao.updateStudent(student);
    System.out.println("修改成功");
}

 

运行成功。

 

三.删除数据

在原文加了ApplicationContext ctx = null;

    ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");

    StudentDao studentDao = (StudentDao) ctx.getBean("StudentDao");

Student student = new Student();这么一句话,加到public void deleteStudentById(){后面。

运行出现错误无效的绑定声明如图:

 

 

deleteStudent变为:deleteStudentById,出现爆红,按住ALT+enter,爆红解决。但是StudentDao,里面的内容多了最后一句话,如图:

public interface StudentDao {
    public void getStudent(Student student);

    public void addStudent(Student student);
 public void updateStudent(Student student);
 public void deleteStudent(int StudentId);

    void deleteStudentById(int i);
}

 

运行,删除数据成功:如图:

 

 四、下载安装了xshell    flashFXP两个软件。


五。根据庆东师兄的建议,今天又复习了下Spring,包括它的注解怎么使用。

我发现一开始看不懂的东西,完成任务后,再回头看,就能多明白不少。


明天的计划:十点钟抢免费的阿里云服务器,进行下一步。这个mybatis和spring框架搭建,有空的时候就做几次

遇到的问题:查询数据自己解决了,修改数据庆东师兄指点了我一下。删除数据自己解决了,但是我自己都不明白有些问题怎么就稀里糊涂的解决了。

今天的收获:自己解决了两个问题

java任务一开始时间:2017.12.05

预计demo时间:2018.01-05

可能有延期风险,原因是:基础太差,很多任务的教程都卡壳,进行不下去。

禅道链接地址:http://task.ptteng.com/zentao/project-task-501.html


 

 

 



返回列表 返回列表
评论

    分享到