Spring注解测试

@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration(locations = "classpath:application.xml") 
@Transactional 
public class Egptest { 
@Autowired 
private RestTemplate restTemplate; 
@Test 
public void aa (){ 
List<Map<String,Object>> list=new ArrayList<Map<String, Object>>(); 
Map<String,Object> aa=new HashMap<String, Object>(); 
aa.put("newWtID","123"); 
aa.put("oldWtID","1111111111"); 
Map<String,Object> bb=new HashMap<String, Object>(); 
bb.put("newWtID","678"); 
bb.put("oldWtID","14596590"); 
list.add(aa); 
list.add(bb); 
String a= JSON.toJSONString(list); 
String result = restTemplate.postForObject("******************", a, String.class); 
System.out.println(result); 

} 
} 

原文地址:https://www.cnblogs.com/duanxianyouyang/p/10676780.html