mybatis spring问题

J2EE 码拜 9年前 (2015-04-23) 1083次浏览 0个评论

初学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;


	}
}
mybatis spring问题
你打印一下异常信息看看
mybatis spring问题
20分
Method  GetKeyidinfo  should be void ;
Method  GetKeyidinfo should have no parameters
mybatis spring问题
80分
JUNIT  测试方法必须为void  并且不能有参数  ,我也是刚学习的

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明mybatis spring问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!