SpringMvc+Spring+mybatis配置文件

web.xml

"1.0" encoding="UTF-8"?>
"http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

    
    
        index.jsp
    
  Archetype Created Web Application
  
  
  	contextConfigLocation
  	
  				 classpath:applicationContext.xml
  	
  
   
       springMVC
       org.springframework.web.servlet.DispatcherServlet
       
       
       
             contextConfigLocation
             
	             classpath:springMVC.xml
             
       
       
       
       0
  
  
       springMVC
       /
  
  
  
  
  
  
  
  
  
  
   
       org.springframework.web.context.ContextLoaderListener
  
 
  
        character
        org.springframework.web.filter.CharacterEncodingFilter
      
          
          encoding
          utf-8
      
  
  
        character
        /*
  
  
  

复制代码

* applicationContext.xml

"1.0" encoding="UTF-8"?>

"http://www.springframework.org/schema/beans"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
                       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
                       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
                       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
                       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
                       ">



     "classpath:*.properties"/>

     "com.zte.shopping.service.impl"/>
    
    "dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        "driverClassName" value="${jdbc.driverClassName}" />
        "url" value="${jdbc.url}" />
        "username" value="${jdbc.username}" />
        "password" value="${jdbc.password}"  />

        "initialSize" value="5" />
        "maxActive" value="10" />
    


  
 "sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      "dataSource" ref="dataSource"/>
      "typeAliasesPackage" value="com.zte.shopping.entity"/>
      "mapperLocations">
           
                classpath:mapper/*Mapper.xml
           
      
    "configLocation" value="classpath:mybatis-config.xml"/>
  
  
 "org.mybatis.spring.mapper.MapperScannerConfigurer">
     "basePackage" value="com.zte.shopping.dao"/>
   
  

`   `
    
    "transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        "dataSource" ref="dataSource" />
    


    "transactionInterceptor" transaction-manager="transactionManager">
        
            "regist" propagation="REQUIRED" rollback-for="java.lang.Exception" />
            "*" propagation="SUPPORTS" />
        
    
    
        "execution(* com.zte.shopping.service.impl.*ServiceImpl.*(..))" id="pc"/>
        "transactionInterceptor" pointcut-ref="pc" />
    


复制代码

* springMVC.xml

"1.0" encoding="UTF-8"?>

"http://www.springframework.org/schema/beans" 
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="
                         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
                         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
                        ">
     
     
     

     "com.zte.shopping.controller" />
    
     
     


     "org.springframework.web.servlet.view.InternalResourceViewResolver">
      "viewClass" value="org.springframework.web.servlet.view.JstlView"  />
          "prefix" value="/WEB-INF/view/" />
          "suffix" value=".jsp" />
     
    
    
    
    
    
   



    

    
    
    "/showMain" view-name="main" />

复制代码

* applicationContext_shiro.xml

"1.0" encoding="UTF-8"?>

"http://www.springframework.org/schema/beans" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
                       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
                       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
                       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
                       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
                       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
                       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
                       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
                       ">
  
   
   
	

	
    
    
    
    "securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
          
          "realms">
                
                      "usernameRealm" />
                      "phoneRealm" />
                      "emailRealm" />
                
          
    
    
    
    "shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    
        
        "securityManager" ref="securityManager" />
        
        
        
        
        "loginUrl" value="/showLogin" />
        
        
        "unauthorizedUrl" value="/unauthorizedUrl.jsp" />
        
     
        
        
        "filterChainDefinitions">
             
	             
	             /showLogin=anon
	             /login=anon
	             /main=authc
	              
	             /student/view=authc,roles[student],perms[student:view]
	             /student/delete=authc,roles[student],perms[student:delete]
	            
	             /student/**=authc,roles[student]
	             /teacher/**=authc,roles[teacher]
	             
             
        
    
    
    
    
    "usernameRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
	     "dataSource" ref="dataSource" />
	     
	     
	     "authenticationQuery">
	            select password from t_user where username = ?
	     
	     
	     
	     "userRolesQuery">
	          
			    select
				   r.rolename
				from  
				   t_user        u
				left join 
				   t_user_role   ur
				on
				   u.id = ur.user_id
				left join
				   t_roles   r
				on
				   r.id = ur.role_id
				where 
				   username = ?
			 
	     
	     
	     
	     
	     "permissionsLookupEnabled" value="true" />
	     
	     "permissionsQuery">
	          
		            select
					   *
					from
					   t_roles r
					left join
					   t_role_permission rp
					on
					   r.id = rp.role_id
					left join
					   t_permissions  p
					on
					   p.id = rp.permisson_id
					where
					   r.rolename = ?
	          
	     
    
    
    
    "phoneRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
	    
	     "authenticationQuery">
	            select password from t_user where phone = ?
	     
	     
	     
	     "userRolesQuery">
	          
			    select
				   r.rolename
				from  
				   t_user        u
				left join 
				   t_user_role   ur
				on
				   u.id = ur.user_id
				left join
				   t_roles   r
				on
				   r.id = ur.role_id
				where 
				   username = ?
			 
	     
	     
	     
	     
	     "permissionsLookupEnabled" value="true" />
	     
	     "permissionsQuery">
	          
		            select
					   *
					from
					   t_roles r
					left join
					   t_role_permission rp
					on
					   r.id = rp.role_id
					left join
					   t_permissions  p
					on
					   p.id = rp.permisson_id
					where
					   r.rolename = ?
	          
	     
    
    
    
    "emailRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
	     "dataSource" ref="dataSource" />
	     "authenticationQuery">
	            select password from t_user where email = ?
	     
	     
	     
	     "userRolesQuery">
	          
			    select
				   r.rolename
				from  
				   t_user        u
				left join 
				   t_user_role   ur
				on
				   u.id = ur.user_id
				left join
				   t_roles   r
				on
				   r.id = ur.role_id
				where 
				   username = ?
			 
	     
	     
	     
	     
	     "permissionsLookupEnabled" value="true" />
	     
	     "permissionsQuery">
	          
		            select
					   *
					from
					   t_roles r
					left join
					   t_role_permission rp
					on
					   r.id = rp.role_id
					left join
					   t_permissions  p
					on
					   p.id = rp.permisson_id
					where
					   r.rolename = ?
	          
	     
    

复制代码

* dataSource.properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/shoppingssm?useUnicode=true&characterEncoding=utf8
jdbc.username=root
jdbc.password=root
复制代码

* log4j.properties

log4j.appender.myconsole=org.apache.log4j.ConsoleAppender


#log4j.appender.myconsole.layout=org.apache.log4j.SimpleLayout
log4j.appender.myconsole.layout=org.apache.log4j.PatternLayout
log4j.appender.myconsole.layout.ConversionPattern=%-5p %m%n

log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.PreparedStatemant=DEBUG

log4j.rootLogger=debug,myconsole
复制代码

* mybatis-config.xml

"1.0" encoding="UTF-8"?>
"-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">


	
	
		
	    
	    "com.github.pagehelper.PageHelper">
	    
	        
	        "dialect" value="mysql"/>
	        
	        
	        
	        
	        "offsetAsPageNum" value="true"/>
	        
	        
	        
	        
	        "rowBoundsWithCount" value="true"/>
	        
	        
	        
	        
	        "pageSizeZero" value="true"/>
	        
	        
	        
	        
	        "reasonable" value="true"/>
	        
	        
	        
	        
	        
	        "params" value="pageNum=pageHelperStart;pageSize=pageHelperRows;"/>
	        
	        
	        "supportMethodsArguments" value="true"/>
	        
	        
	        "returnPageInfo" value="true"/>
	    
	
	


复制代码

你可能感兴趣的:(SpringMvc+Spring+mybatis配置文件)