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个回答

@Test方法

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

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问