ssm框架搭建-整合logback实现日志管理(spring5.0)

ssm(spring+springmvc+mybatis)框架搭建:整合mybatis-generato代码生成器,很纯净的基本搭建。

搭建环境:idea+Tomcat 8+jdk 8    用Maven进行管理

1.项目结构:

ssm框架搭建-整合logback实现日志管理(spring5.0)_第1张图片

2.文件对应说明,在readme里面有详细说明。

    jdbc.properties: 数据库配置,druid数据源配置

    mgb.xml:  mybatis代码生成器配置

    logback.xml:  logback日志配置

    spring-mvc.xml:  spring与springmvc配置

    spring-mybatis.xml: spring整合mybatis

    web.xml :整合配置

3.下面贴出文件的详细配置

1) jdbc.properties

ssm框架搭建-整合logback实现日志管理(spring5.0)_第2张图片

2) mgb.xml






    
       
        
            
        

        
        
        

        
            
        

        
        
            
            
        

        
        
            
        

        
        
            
        


        
        

3)logback.xml



    
    
    
    
    
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
    
    
    
        
            
            ${LOG_HOME}/TestWeb.log.%d{yyyy-MM-dd}.log
            
            30
        
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
        
        
            10MB
        
    

    
    
        
    

4)spring-mvc.xml



    
    
    
    
        
            
            
                
                    
                        application/json;charset=UTF-8
                    
                
                
                    
                        
                        WriteDateUseDateFormat
                        QuoteFieldNames
                    
                
            
            
                
                    text/html;charset=UTF-8
                
            
        
    
    
    
    
    
        
    
    
    
        
        
    
    
    
        
        
        
        
        
        
    
    
    
        
        
            
            
            
                
                    
                        /login
                    
                
            
        
    


5)spring-mybatis.xml



    
    
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
    
        
        
        
    
        
            
                
                    
                        
                        
                            helperDialect=oracle
                        
                    
                
            
        

    
    
    
        
        
            
        
    
    
    
    
    
        
    
    
    
        
        
        
    
    
        
            
            
            
            
            
            
            
            
            
            
            
            
            
        
    
    
    



6)web.xml




  Archetype Created Web Application

  
  
    logbackConfigLocation
    classpath:config/logback.xml
  
  
    ch.qos.logback.ext.spring.web.LogbackConfigListener
  

  
  
    contextConfigLocation
    classpath:config/spring-*.xml
  
  
  
    SpringEncodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
      encoding
      UTF-8
    
    
      forceEncoding
      true
    
  
  
    SpringEncodingFilter
    /*
  
  
  
    org.springframework.web.context.ContextLoaderListener
  
  
  
    org.springframework.web.util.IntrospectorCleanupListener
  
  
  
    spring
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      
        classpath:config/spring-mvc.xml
      
    
    1
  
  
    spring
    /
  
  
  
    DruidWebStatFilter
    com.alibaba.druid.support.http.WebStatFilter
    true
    
      exclusions
      /static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
    
    
      sessionStatMaxCount
      1000
    
  
  
    DruidWebStatFilter
    /*
  
  
  
    DruidStatView
    com.alibaba.druid.support.http.StatViewServlet
    
    true
  
  
    DruidStatView
    /druid/*
  
  
  
    default
    /static/*
  


7) pom文件




    4.0.0

    com.ke.demo
    logbackTest
    1.0-SNAPSHOT
    war
    logbackTest Maven Webapp
    
    http://www.example.com
    
        UTF-8
        1.7
        1.7
        1.1.7
        1.7.21
        
        5.0.0.RELEASE
        
        3.4.5
        1.3.2
    
    
        
            junit
            junit
            4.11
            test
        
        
        
            org.slf4j
            slf4j-api
            ${slf4j.version}
            compile
        
        
            ch.qos.logback
            logback-core
            ${logback.version}
        
        
            ch.qos.logback
            logback-classic
            ${logback.version}
        
        
            org.logback-extensions
            logback-ext-spring
            0.1.1
        


        
        
            org.springframework
            spring-core
            ${spring.version}
        

        
            org.springframework
            spring-web
            ${spring.version}
        
        
            org.springframework
            spring-oxm
            ${spring.version}
        
        
            org.springframework
            spring-tx
            ${spring.version}
        
        
            org.springframework
            spring-jdbc
            ${spring.version}
        
        
            org.springframework
            spring-webmvc
            ${spring.version}
        
        
            org.springframework
            spring-aop
            ${spring.version}
        
        
            org.springframework
            spring-context-support
            ${spring.version}
        
        
            org.springframework
            spring-test
            ${spring.version}
            test
        
        
        
            org.springframework
            spring-beans
            ${spring.version}
        
        
        
        
            org.aspectj
            aspectjrt
            1.8.8
        
        
            org.aspectj
            aspectjweaver
            1.8.3
        
        
        
        
            org.mybatis
            mybatis
            ${mybatis.version}
        
        
            com.github.pagehelper
            pagehelper
            4.1.6
        
        
            tk.mybatis
            mapper
            3.3.8
        
        
        
            org.mybatis
            mybatis-spring
            1.3.1
        
        
        
            javax
            javaee-api
            8.0
            provided
        
        
        
            mysql
            mysql-connector-java
            
            5.1.39
        
        
        
            jstl
            jstl
            1.2
        
        
        
            commons-fileupload
            commons-fileupload
            1.3.3
        
        
            commons-io
            commons-io
            2.6
        
        
            commons-codec
            commons-codec
            1.11
        
        
        
        
            org.mybatis.generator
            mybatis-generator-core
            1.3.7
        
        
        
            com.alibaba
            druid
            0.2.23
        
        
        
            com.alibaba
            fastjson
            1.2.42
        
        
            org.codehaus.jackson
            jackson-mapper-asl
            1.9.13
        
    
    
        logbackTest
        
            
                
                    maven-clean-plugin
                    3.0.0
                
                
                
                    maven-resources-plugin
                    3.0.2
                
                
                    maven-compiler-plugin
                    3.7.0
                
                
                    maven-surefire-plugin
                    2.20.1
                
                
                    maven-war-plugin
                    3.2.0
                
                
                    maven-install-plugin
                    2.5.2
                
                
                    maven-deploy-plugin
                    2.8.2
                
            
        
    

8)测试sql

/*
Navicat MySQL Data Transfer

Source Server         : mysql本地
Source Server Version : 50561
Source Host           : 127.0.0.1:3306
Source Database       : test

Target Server Type    : MYSQL
Target Server Version : 50561
File Encoding         : 65001

Date: 2018-11-15 10:30:51
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for base_user
-- ----------------------------
DROP TABLE IF EXISTS `base_user`;
CREATE TABLE `base_user` (
  `name` varchar(255) DEFAULT NULL,
  `id` int(11) NOT NULL,
  `age` int(11) DEFAULT NULL,
  `sex` char(2) DEFAULT NULL,
  `note` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of base_user
-- ----------------------------
INSERT INTO `base_user` VALUES ('张三', '1', '18', '男', '无');
INSERT INTO `base_user` VALUES ('李四', '2', '19', '女', '122');

项目源码地址:

 1.csdn下载: https://download.csdn.net/download/ke_new/10787985

 2.关注公众号,回复001         =-=

ssm框架搭建-整合logback实现日志管理(spring5.0)_第3张图片

 

你可能感兴趣的:(ssm)