maven+ssm的配置文件大致模样

最近做了两个小项目,maven+ssm框架都是分配到别人那里搭的,感觉久了没碰配置,心理未免有点恐慌,所以整理了下maven+ssm配置文件的大致模样。后面会附上每个配置文件的具体内容。

搭建一个maven的ssm流程:

一、pom.xml中必要的依赖有

1. commons族

commons-logging
commons-lang
commons-io
commons-beanutils
(commons-pool)

2. json

jackson-mapper-asl
jackson-core-asl
jackson-databind

3. mybatis族

mysql-connector-java
druid
mybatis
mybatis-spring

4. Spring-SpringMVC族

spring-aop
spring-aspects
spring-beans
spring-context
spring-context-support
spring-core
spring-expression
spring-jdbc
spring-orm
spring-test
spring-tx
spring-webmvc
spring-web
spring-jms

5. aop相关

aspectjrt
aspectjwweaver
aspectjlib
aopalliance

6. JSP相关

jstl
servlet-api
jap-api

7. 上传下载

commons-io
commons-fileupload
poi
spring-data-redis

8. dubbo

dubbo:


    com.alibaba
    dubbo
    
        
            spring
            org.springframework
        
        
            netty
            org.jboss.netty
        
    

zookeeper
zkclient

9. redis

jedis

10. 常用plugin

tomcat7

11. 其他

     
          
            src/main/java
                       
                              **/*.properties
                              **/*.xml
                       
                       
                false
            
           
                src/main/resources
                         
                            **/*.properties 
                            **/*.xml
                       
                 true
           
    

二、配置流程

0. web.xml

配置spring相关的配置文件的监听(contextConfigLocation);
配置字符过滤器(CharactorEncodingFilter,如果处理get请求中文乱码,先写一个wrapper);
配置spring监听器;
配置springMVC的Dispatcher文件

1. mybatis-config.xml

ssm中,mybatis被集成托管到了spring里,所以一般此配置中只开启mybatis日志;

2. spring-dao.xml

扫描dao包下的Dao和Mapper,并根据文件名相映射;
引入数据库连接相应的properties文件;
配置(druid)dataSource连接池;
在sqlSessionFactory中整合dataSource、mybatis-config.xml的文件路径(configLocation)、mapper的文件路径(mapperLocations);
将Mapper和Dao绑定;

3. spring-service.xml

扫描含有@Service注解的service实体类

4. spring-transaction.xml

定义事务管理器(DataSourceTransactionManager);
配置事务管理的建议(txAdvice);
配置事务aop目标

5. springmvc-servlet.xml

配置要扫描的controller/aop/interceptor包;
mvc注解驱动(mvc:annotation-driven)
开启aop面向切面自动代理(aop:aspectj-autoproxy);
配置视图解析器(jsp||html);
配置静态资源获取(mvc:default-servlet-handler);
配置拦截器(mvc:interceptors);

以下是每个配置文件的具体内容

这些配置文件是从一次项目中复制出来的,具体配置还是要根据实际项目来配置

pom.xml



    4.0.0

    com.zlt
    sms
    0.0.1-SNAPSHOT
    war

    bbd Maven Webapp
    
    http://www.example.com

    
        UTF-8
        1.7
        1.7
    

    

        
            junit
            junit
            4.11
            test
        
        
        
            commons-logging
            commons-logging
            1.1.3
        
        
            commons-lang
            commons-lang
            2.5
        
        
            commons-io
            commons-io
            2.5
        
        
            commons-beanutils
            commons-beanutils
            1.8.0
        
        
        
            org.apache.commons
            commons-pool2
            2.4.2
        


        
        
            org.codehaus.jackson
            jackson-mapper-asl
            1.9.4
        
        
            org.codehaus.jackson
            jackson-core-asl
            1.9.4
        
        
            com.fasterxml.jackson.core
            jackson-databind
            2.8.9
        


        
        
            javax.servlet
            jstl
            1.1.2
        
        
        
            taglibs
            standard
            1.1.2
        
        
        
        
            javax.servlet.jsp
            javax.servlet.jsp-api
            2.2.1
            provided
        
        
        
            javax.servlet
            javax.servlet-api
            4.0.1
            provided
        

        
        
            javax.servlet
            jsp-api
            2.0
            provided
        



        
        
            mysql
            mysql-connector-java
            5.1.32
        
        
        
            com.alibaba
            druid
            1.0.23
            compile
        
        
        
            org.mybatis
            mybatis-spring
            1.2.2
        
        
            org.mybatis
            mybatis
            3.2.3
        


        
        
            org.springframework
            spring-aop
            4.3.10.RELEASE
        
        
            org.springframework
            spring-aspects
            4.3.10.RELEASE
        
        
            org.springframework
            spring-beans
            4.3.10.RELEASE
        
        
            org.springframework
            spring-context
            4.3.10.RELEASE
        
        
            org.springframework
            spring-context-support
            4.0.6.RELEASE
        
        
            org.springframework
            spring-core
            4.3.10.RELEASE
        
        
            org.springframework
            spring-expression
            4.3.10.RELEASE
        
        
            org.springframework
            spring-jdbc
            4.0.6.RELEASE
        
        
            org.springframework
            spring-orm
            4.0.6.RELEASE
        
        
            org.springframework
            spring-test
            4.0.6.RELEASE
        
        
            org.springframework
            spring-tx
            3.2.8.RELEASE
        
        
            org.springframework
            spring-webmvc
            4.3.10.RELEASE
        
        
            org.springframework
            spring-web
            4.3.10.RELEASE
        

        
        
        
            commons-io
            commons-io
            2.5
        
        
        
            commons-fileupload
            commons-fileupload
            1.3.1
        
        
        
            org.apache.poi
            poi
            3.8
        

        
        
            org.springframework.data
            spring-data-redis
            1.6.2.RELEASE
        

        
        
            redis.clients
            jedis
            2.8.0
        

        
        
        
            aopalliance
            aopalliance
            1.0
        
        
        
            org.aspectj
            aspectjlib
            1.6.2
        
        
        
            org.aspectj
            aspectjrt
            1.8.9
        
        
        
            org.aspectj
            aspectjweaver
            1.8.9
        




    

    
        
        
            
                src/main/java
                
                    **/*.properties
                    **/*.xml
                
                
                false
            
            
                src/main/resources
                
                    **/*.properties
                    **/*.xml
                
                true
            
        

        bbd
        
            


                
                
                    org.apache.tomcat.maven
                    tomcat7-maven-plugin
                    2.2

                    
                        /
                        8080
                    
                


                
            
        
    


web.xml




    Archetype Created Web Application

    
    
        contextConfigLocation
        classpath:com/sms/config/spring/spring-*.xml
    

    
        CharactorEncodingFilter
        CharactorEncodingFilter
        
        com.sms.filter.CharactorEncodingFilter
    
    
        CharactorEncodingFilter
        /CharactorEncodingFilter
    


    
    
        org.springframework.web.context.ContextLoaderListener
    


    
    
        ssm
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:com/sms/config/spring/springmvc-servlet.xml
        
        1
    
    
        ssm
        *.do
    


mybatis-config.xml




     

    
     
     

    


spring-dao.xml




    
    
    


    
    
        
        
        
        
        


        
        
        
        

        
        

        
        

        
        

        
        
        
        

        
        
        

        
        
    


    
    
        
        
        
    

    
    
    



spring-service.xml




    
    
    

spring-transaction.xml

 



    
    
    
    
    
          
            
            
            
            
            
         
    
    
      
          
          
      

springmvc-servlet.xml




    
    
    
    
    

    
    
    

    
    
    
    
    
        
        
        
    
    
    
    
        
            
            
        
    
    

你可能感兴趣的:(maven+ssm的配置文件大致模样)