SSM项目配置文件及其各项使用

$说明:

   ·Spring 5  + Mybatis 3.4.5 +SpringMVC 

   ·使用druid数据库

   ·使用log4j输出日志

$Spring 及其配置文件(部分)

Spring官方网站:http://spring.io/

Spring重点: 

  ·IOC(控制反转)

  ·DI(依赖注入)

  ·AOP (面向切面编程)


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

    
    
    
    
    
    package="com.xxx.*" />

    
    class="com.alibaba.druid.pool.DruidDataSource">
        
        
        
        

    

    
    class="org.mybatis.spring.SqlSessionFactoryBean">
        
        
         
          
          
        
    


    
    class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        
    
 

$ Mybatis 及其配置(部分)

Mybatis官方网站:http://blog.mybatis.org/

Mybatis下载地址:https://github.com/mybatis/mybatis-3/releases

Mybatis重点:

    ·全局配置文件

    ·Mybatis映射文件

    ·动态SQL

    ·一对多,多对一等关系

DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">


    
    
        
    

<部分代码可写入Spring中>

$SpringMVC 及其配置(部分)

SpringMVC无缝接入Spring ,可在Spring官网中及其文档中查看

SpringMVC重点

    ·控制器的使用Controller

    ·json

    ·放行静态资源:*.js  *.css *.jpg等

    ·拦截器

    ·核心:前端控制器(DispatcherServlet

    ·多视图控制


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc"

    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.2.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
           http://www.springframework.org/schema/mvc
           http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
           ">
            
            
              
              package="com.xxx.controller"/>
              
              
              
              
                  
              default-servlet-handler/>
              
              
              
              
              
              
              
              
              
              
              class="com.xxx.Interceptor.CheckLoginInterceptor"/>
              
              
              
              
              
              
              
           class="org.springframework.web.servlet.view.InternalResourceViewResolver">
           
           
           
           
      
           

$其他配置(部分)

  ·log4j日志配置:

#日志的基本设置
# 设置日志的全局配置,级别越小显示的越详细  tracefatal
log4j.rootLogger=debug, stdout
# log4j.logger.加需要输出的包的路径  并设置日志级别
log4j.logger.com.Mapping=TRACE
# Console output...  将文件输出达到某个位置  ConsoleAppender 输出到控制台
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

 

  ·druid数据库配置:

#druid基本配置
druid.url=jdbc:mysql://127.0.0.1/springmvc?useUnicode=true&characterEncoding=utf8
druid.driverClassName=com.mysql.jdbc.Driver
druid.username=root
druid.password=082999

$注意:

    ·部分包名如: com.xxx.Controller      是自用包名。请读者详细查看后记得修改。 不然会报配置文件无效相关的错误。

 

转载于:https://www.cnblogs.com/CllOVER/p/10296511.html

你可能感兴趣的:(SSM项目配置文件及其各项使用)