e1c98c9a5a3f63c953793af95c212ca2189a60aa.svn-base 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package org.zsl.testmybatis;
  2. /*
  3. import javax.annotation.Resource;
  4. import org.apache.log4j.Logger;
  5. import org.junit.Before;
  6. import org.junit.Test;
  7. import org.junit.runner.RunWith;
  8. import org.springframework.context.ApplicationContext;
  9. import org.springframework.context.support.ClassPathXmlApplicationContext;
  10. import org.springframework.test.context.ContextConfiguration;
  11. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  12. import com.alibaba.fastjson.JSON;
  13. import com.cn.hnust.pojo.User;
  14. import com.cn.hnust.service.IUserService;
  15. @RunWith(SpringJUnit4ClassRunner.class) //表示继承了SpringJUnit4ClassRunner类
  16. @ContextConfiguration(locations = {"classpath:spring-mybatis.xml"})
  17. public class TestMyBatis {
  18. private static Logger logger = Logger.getLogger(TestMyBatis.class);
  19. // private ApplicationContext ac = null;
  20. @Resource
  21. private IUserService userService = null;
  22. // @Before
  23. // public void before() {
  24. // ac = new ClassPathXmlApplicationContext("applicationContext.xml");
  25. // userService = (IUserService) ac.getBean("userService");
  26. // }
  27. @Test
  28. public void test1() {
  29. User user = userService.getUserById(1);
  30. // System.out.println(user.getUserName());
  31. // logger.info("值:"+user.getUserName());
  32. logger.info(JSON.toJSONString(user));
  33. }
  34. }*/