当前位置: 代码迷 >> J2EE >> mybatis spring有关问题
  详细解决方案

mybatis spring有关问题

热度:89   发布时间:2016-04-17 23:14:47.0
mybatis spring问题
初学mybatis spring 和struts2

遇到个问题请教下

@RunWith(SpringJUnit4ClassRunner.class)
@org.springframework.test.context.ContextConfiguration(locations={"file:WebRoot/WEB-INF/applicationContext.xml"}) 
public class CheckUtil {

@Autowired
private CheckkeyidMapper checkkeyidMapper;
@Test
public void GetKeyidinfo(){
String Status = "N";
Map map = new HashMap();
map.put("name","gg");  
map.put("keyid","2");
try {
        int count = checkkeyidMapper.checkkeyid(map);
if(count == 0){
     Status = "E";
     }
}catch (Exception e) {
Status = "E";
    }

}

}
  这样用JUnit运行测试是正常的

可是我换成public String GetKeyidinfo(String name, String keyid) 传入参数在程序里面调用,
int count = checkkeyidMapper.checkkeyid(map); 不执行也没有结果,不知道是什么原因
public class CheckUtil {

@Autowired
private CheckkeyidMapper checkkeyidMapper;
@Test
public String GetKeyidinfo(String name, String keyid){
String Status = "N";
Map map = new HashMap();
map.put("name","gg");  
map.put("keyid","2");
try {
System.out.println("map+++++"+map);
        int count = checkkeyidMapper.checkkeyid(map);
        System.out.println("count ==========================="+count);
if(count == 0){
     Status = "E";
     }
}catch (Exception e) {
Status = "E";
    }
return Status;


}
}

------解决思路----------------------
Method  GetKeyidinfo  should be void ;
Method  GetKeyidinfo should have no parameters
------解决思路----------------------
JUNIT  测试方法必须为void  并且不能有参数  ,我也是刚学习的
  相关解决方案