SSM 프레임 워 크 + maven 통합 구축

8169 단어 Spring
  • Maven 패키지 의존
    
    		
    			org.apache.struts
    			struts2-core
    			2.5.1
    		
    		
    		
    		
    			org.mybatis
    			mybatis
    			3.2.1
    		
    
        
            org.springframework
            spring-context
            3.2.18.RELEASE
        
    	
    	
    	    org.springframework
    	    spring-test
    	    3.2.18.RELEASE
    	    test
    	
    		
    	
    	    org.springframework
    	    spring-core
    	    3.2.18.RELEASE
    	
    		
    	
    	    org.springframework
    	    spring-web
    	    3.2.18.RELEASE
    	
    		
    	
    	    org.springframework
    	    spring-aop
    	    3.2.18.RELEASE
    	
    	
    
    
        aspectj
        aspectjweaver
        1.5.4
    
    
    	
    		
    	
    	    org.springframework
    	    spring-tx
    	    3.2.18.RELEASE
    	
    	
    	
    	    org.springframework
    	    spring-jdbc
    	    3.2.18.RELEASE
    	
    	
    
        org.springframework
        spring-orm
        3.2.18.RELEASE
    
    
        
        
    
        org.apache.struts
        struts2-spring-plugin
        2.3.33
    
    
      
          org.mybatis
          mybatis-spring
          1.3.1
        
    
     
        
    
        
        commons-dbcp
        commons-dbcp
        1.4
    
    
    
        commons-pool
        commons-pool
        1.6
    
  • struts 와 spring 통합
      
    		
    	
    		s2
    		org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
    	
    	
    		s2
    		/*
    	
    		
    	
    		
    	
    		org.springframework.web.context.ContextLoaderListener
    	
    	
    	
    		contextConfigLocation
    		classpath:/com/yufan/util/applicationContext.xml
    	
    웹. xml 에 추가 할 코드
  • my batis 와 spring 통합
  •                 
        주: 원래 my batis - configxml 의 설정 은 별명 속성 을 설정 하 는 것 을 제외 하고 다른 설정 정 보 는 모두 spring 설정 파일 로 이동 하 였 습 니 다.
    
    		
    	
    			
    		
    

    다음은 spring 의 프로필 applicationContext. xml 의 내용 을 구체 적 으로 소개 합 니 다.
    1.
    	
    	

    2.
    	
    	
        		
        			${driver}
        		
        		
        			${url}
        		
        		
        			root
        		
        		
        			${password}
        		
        	

    3. sqlSession Factory 공장 설립
        		
    	
    		
    
    		
    		 
    	
    

          mapperLocation mapper 의 xml 맵 파일 
           type: Aliases 패키지 실체 클래스
     4. dao 층 에 트 랜 잭 션 제어 추가 (정례 화)
    
    		
    		
    	
    	

        dao 는 인터페이스 여야 합 니 다.
        공장 설정 에 따라 맵 파일 을 자동 으로 연결 하여 정례 화 합 니 다.
        사용 방법:
        ApplicationContext applicationContext = new 
    				ClassPathXmlApplicationContext("/com/yufan/util/applicationContext.xml");
    		UserDao userDao = (UserDao)applicationContext.getBean("userDao");
    		User u = new User(1, "yufan","yufan", true,20);
    		userDao.saveUser(u);
    		System.out.println("  ");

    5. 트 랜 잭 션 제어
    
    	
    		
    	
    	
    	
    		
    			
    			
    			
    			
    			
    			
    			
    			
    		
    	
    	
    	
    	
    	   
       
    		
    		
    	
    

    6. 서비스 층
    
    		
    	

    7. action 층
    	
    		
    	

    좋은 웹페이지 즐겨찾기