From a4a15ca266bd2e503c15ea0aabd739e38ebb941b Mon Sep 17 00:00:00 2001 From: shimingxy Date: Sun, 26 May 2019 14:29:51 +0800 Subject: [PATCH] rm --- README.md | 63 +++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index ecdd95a..b71bc2e 100644 --- a/README.md +++ b/README.md @@ -212,12 +212,11 @@ public class MyBatisTestRunner { private static final Logger _logger = LoggerFactory.getLogger(MyBatisTestRunner.class); public static ApplicationContext context; + public static StudentsService service; @Test public void insert() throws Exception{ _logger.info("insert..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); Students student=new Students(); student.setStdNo("10024"); student.setStdGender("M"); @@ -225,17 +224,15 @@ public class MyBatisTestRunner { student.setStdAge(20); student.setStdMajor("政治"); student.setStdClass("4"); - ss.insert(student); + service.insert(student); Thread.sleep(1000); - ss.remove(student.getId()); + service.remove(student.getId()); } @Test public void get() throws Exception{ _logger.info("get..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); - Students student=ss.get("921d3377-937a-4578-b1e2-92fb23b5e512"); + Students student=service.get("921d3377-937a-4578-b1e2-92fb23b5e512"); _logger.info("Students "+student); } @@ -243,33 +240,27 @@ public class MyBatisTestRunner { @Test public void remove() throws Exception{ _logger.info("remove..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); Students student=new Students(); student.setId("921d3377-937a-4578-b1e2-92fb23b5e512"); - ss.remove(student.getId()); + service.remove(student.getId()); } @Test public void batchDelete() throws Exception{ _logger.info("batchDelete..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); List idList=new ArrayList(); idList.add("8584804d-b5ac-45d2-9f91-4dd8e7a090a7"); idList.add("ab7422e9-a91a-4840-9e59-9d911257c918"); idList.add("12b6ceb8-573b-4f01-ad85-cfb24cfa007c"); idList.add("dafd5ba4-d2e3-4656-bd42-178841e610fe"); - ss.batchDelete(idList); + service.batchDelete(idList); } @Test public void findAll() throws Exception{ _logger.info("findAll..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); - _logger.info("findAll "+ss.findAll()); + _logger.info("findAll "+service.findAll()); } @Before @@ -293,21 +284,11 @@ public class MyBatisTestRunner { //Initialization ApplicationContext for Project public void init(){ _logger.info("init ..."); - String path_str=MyBatisTestRunner.class.getResource("ApplicationRunner.properties").getFile().toString(); - String appRunnerClassPath=path_str.substring(0,path_str.indexOf("org")); - _logger.info("Application class "+appRunnerClassPath); - - System.setProperty("APPRUNNER_CLASSPATH",appRunnerClassPath); - String appRunnerPath=path_str.substring( - path_str.startsWith("/")?1:0, - path_str.indexOf(appRunnerClassPath.split("/")[appRunnerClassPath.split("/").length-1])); - System.setProperty("APPRUNNER_PATH",appRunnerPath); - - _logger.info("appRunner dir "+appRunnerPath); - _logger.info("Application dir "+System.getProperty("user.dir")); context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"}); + WebContext.applicationContext=context; + service =(StudentsService)WebContext.getBean("studentsService"); } } @@ -343,28 +324,24 @@ public class MyBatisTestRunner { @Test public void queryPageResults() throws Exception{ _logger.info("queryPageResults..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); Students student=new Students(); //student.setId("af04d610-6092-481e-9558-30bd63ef783c"); student.setStdGender("M"); //student.setStdMajor(政治"); student.setPageResults(10); student.setPage(2); - _logger.info("queryPageResults "+ss.queryPageResults(student)); + _logger.info("queryPageResults "+service.queryPageResults(student)); } @Test public void queryPageResultsByMapperId() throws Exception{ _logger.info("queryPageResults by mapperId..."); - WebContext.applicationContext=context; - StudentsService ss=(StudentsService)WebContext.getBean("studentsService"); Students student=new Students(); student.setStdGender("M"); //student.setStdMajor(政治"); student.setPageResults(10); student.setPage(2); - _logger.info("queryPageResults by mapperId "+ss.queryPageResults("queryPageResults1",student)); + _logger.info("queryPageResults by mapperId "+service.queryPageResults("queryPageResults1",student)); } @@ -389,21 +366,9 @@ public class MyBatisTestRunner { //Initialization ApplicationContext for Project public void init(){ _logger.info("init ..."); - String path_str=MyBatisTestRunner.class.getResource("ApplicationRunner.properties").getFile().toString(); - String appRunnerClassPath=path_str.substring(0,path_str.indexOf("org")); - _logger.info("Application class "+appRunnerClassPath); - - System.setProperty("APPRUNNER_CLASSPATH",appRunnerClassPath); - String appRunnerPath=path_str.substring( - path_str.startsWith("/")?1:0, - path_str.indexOf(appRunnerClassPath.split("/")[appRunnerClassPath.split("/").length-1])); - - System.setProperty("APPRUNNER_PATH",appRunnerPath); - - _logger.info("appRunner dir "+appRunnerPath); - _logger.info("Application dir "+System.getProperty("user.dir")); context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"}); - + WebContext.applicationContext=context; + service =(StudentsService)WebContext.getBean("studentsService"); } } @@ -456,7 +421,7 @@ public class MyBatisTestRunner { - SELECT ID , STDNO , -- GitLab