qq_39544334
2017-08-10 10:15 阅读 819

mybaits 测试类junit报错

package com.jiyun.mybaits.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import com.jiyun.mybaits.pojo.User;

public class JunitTest {

@Test
private void test1() throws IOException {
    // TODO Auto-generated method stub
    String resource = "SqlMapConfig.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    SqlSession openSession = sessionFactory.openSession();
    List<User> userList = openSession.selectList("test.selectAllUser");
    for (User user : userList) {
        System.out.println(user.getUsername() + "--" + user.getPassword() + "--" + user.getSex());
    }
    openSession.close();
}

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • Small_Mouse0 鼠小 2017-08-11 02:17

    @Test方法

    写成 public,,,,,private 可能找不到的

    对你有帮助给个采纳......................^.^

    点赞 评论 复制链接分享

相关推荐