<?xml version="1.0" encoding="UTF-8"?> <beans ……> …… <bean id="crud.mybatis.auto_dao.ssf" ……> …… </bean> <bean id="crud.mybatis.auto_dao.userMgrSvc" class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.service._01_UserMgrService"> <property name="userDAO" ref="crud.mybatis.auto_dao.userDAO"/> </bean> </beans>
…… public class _02_MyBatisDAO_and_Service_with_Spring extends A_UserMgrTestCaseBase { …… private I_UserDAO userDAO; private _01_UserMgrService userMgrSvc; @Test public void testObjects() throws IOException { …… session.close(); System.out.println("SqlSession Closed:\n\t" + session); _01_UserMgrService userMgrSvc = new _01_UserMgrService(); userMgrSvc.setUserDAO(userDAO); System.out.println("Service:\n\t" + userMgrSvc); } @Test public void testObjects2() throws IOException { …… // I_UserDAO userDAO = session.getMapper(I_UserDAO.class); I_UserDAO userDAO = actxt.getBean("crud.mybatis.auto_dao.userDAO", I_UserDAO.class); System.out.println("DAO:\n\t" + userDAO); // session.close(); // System.out.println("SqlSession Closed:\n\t" + session); // _01_UserMgrService userMgrSvc = new _01_UserMgrService(); // userMgrSvc.setUserDAO(userDAO); _01_UserMgrService userMgrSvc = actxt.getBean( "crud.mybatis.auto_dao.userMgrSvc", _01_UserMgrService.class); System.out.println("Service:\n\t" + userMgrSvc); actxt.close(); System.out.println("Application Context Closed:\n\t" + actxt); } @Before public void init() // throws IOException { …… userDAO = actxt.getBean("crud.mybatis.auto_dao.userDAO", I_UserDAO.class); System.out.println("DAO:\n\t" + userDAO); userMgrSvc = actxt.getBean("crud.mybatis.auto_dao.userMgrSvc", _01_UserMgrService.class); System.out.println("Service:\n\t" + userMgrSvc); } @After public void close() { …… } …… @Test public void testUserDAO_discardById() throws SQLException { …… } @Test public void testUserMgrSvc_createUser() throws SQLException { …… } …… private void showUsers(List<User> lstUsers) { …… } }
<?xml version="1.0" encoding="UTF-8"?> <beans ……> …… <bean id="crud.mybatis.auto_dao.userMgrSvc" ……> …… </bean> <bean id="crud.mybatis.auto_dao.userMgrCtrl" class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.controller._01_UserMgrController"> <property name="userMgrSvc" ref="crud.mybatis.auto_dao.userMgrSvc"/> <property name="pageTitle" value="Integration&nbsp;Demo / 04&nbsp;Spring&nbsp;Web&nbsp;MVC / 02&nbsp;Create,&nbsp;Read,&nbsp;Update&nbsp;&amp;&nbsp;Discard / 03&nbsp;MyBatis&nbsp;CRUD / 02&nbsp;Auto&nbsp;DAO&nbsp;Way / 01&nbsp;User&nbsp;Management - "/> <property name="jumpTarget"> <props> <prop key="result">/WEB-INF/pages/tfw/integration_demo/04_spring_web_mvc/02_crud/01_basic_jdbc_crud/01_user_mgr/result.jsp</prop> <prop key="detail">/WEB-INF/pages/tfw/integration_demo/04_spring_web_mvc/02_crud/01_basic_jdbc_crud/01_user_mgr/detail.jsp</prop> <prop key="login">/WEB-INF/pages/tfw/integration_demo/04_spring_web_mvc/02_crud/03_mybatis_crud/02_auto_dao_way/01_user_mgr/login.html</prop> <prop key="list">/WEB-INF/pages/tfw/integration_demo/04_spring_web_mvc/02_crud/01_basic_jdbc_crud/01_user_mgr/list.jsp</prop> </props> </property> </bean> </beans>
<?xml version="1.0" encoding="UTF-8"?> <beans ……> …… <bean id="crud.mybatis.manual_dao.userMgrCtrl" ……> …… </bean> <bean id="crud.mybatis.urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/tfw/integration_demo/04_spring_web_mvc/02_crud/03_mybatis_crud/01_manual_dao_way/01_user_mgr/action.spr">crud.mybatis.manual_dao.userMgrCtrl</prop> <prop key="/tfw/integration_demo/04_spring_web_mvc/02_crud/03_mybatis_crud/02_auto_dao_way/01_user_mgr/action.spr">crud.mybatis.auto_dao.userMgrCtrl</prop> </props> </property> </bean> <!-- [########################################] --> <bean id="crud.mybatis.auto_dao.msc" ……> …… </bean> …… </beans>