请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答

插入代码

1回答

同学您好,单凭这些信息翔仔这边没办法推断呢,请问test里面是如何填写的,我这边是这样填写的(简略版)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.imooc.o2o.dao;
 
import static org.junit.Assert.assertEquals;
 
import java.util.List;
 
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
 
import com.imooc.o2o.BaseTest;
import com.imooc.o2o.entity.Area;
 
public class AreaDaoTest extends BaseTest{
    @Autowired
    private AreaDao areaDao;
     
    @Test
    public void testQueryArea(){
        List<Area> areaList = areaDao.queryArea();
        assertEquals(2, areaList.size());
    }
}

同时BasetTest是这样的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.imooc.o2o;
 
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
/**
 
 * 配置spring和junit整合,junit启动时加载springIOC容器
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
// 告诉junit spring配置文件的位置
@ContextConfiguration({ "classpath:spring/spring-dao.xml"})
public class BaseTest {
 
}

还请同学对照视频里的spring-dao.xml以及mybatis-config.xml进行配置。有不懂的问题可以在群里提问,这些问题相信同学们都遇到过


0 回复 有任何疑惑可以回复我~
  • 提问者 qq_龌龊少年_0 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2017-11-13 21:08:23
  • 提问者 qq_龌龊少年_0 #2
    谢谢老师,已解决,是我自己配置弄错了
    回复 有任何疑惑可以回复我~ 2017-11-13 21:09:17
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号