一、配置文件的分工

  spring配置文件:

    1、配置扫描包,排除Controller、ControllerAdvice

    2、导入属性文件

    3、数据库连接池的数据源

    4、配置事务管理器(datasource属性)

    5、开启基于注解的事务<tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>

    6、配置SqlSessionFactoryBean对象,(dataSource和configLocation属性)

    7、配置MapperScannerConfigurer对象(basePackage属性:mapper包扫描)

 Spring配置文件applicationContext.xml

  mybatis配置文件:

    1、settings的配置

      配置:数据库字段转换为驼峰式命名

      开启二级缓存

      开启懒加载

 MyBatis配置文件mybatis-config.xml

  spring mvc配置文件:

    1、配置扫描包,只扫描Controller、ControllerAdvice

    2、配置视图解析器InternalResourceViewResolver

    3、配置处理静态资源文件:<mvc:default-servlet-handler/>

    4、配置<mvc:annotation-driven></mvc:annotation-driven>

    5、配置<mvc:view-controller path="/abc" view-name="success"/>

 Spring MVC配置文件springmvc.xml

  web.xml配置文件:

    1、配置生命周期监听器ContextLoaderListener,加载IOC容器

    2、配置前端控制器DispatcherServlet

    3、配置字符集过滤器CharacterEncodingFilter

    4、配置Spring MVC过滤器HiddenHttpMethodFilter,使得支持GET、POST、PUT与DELETE请求

 web.xml配置文件

二、创建动态Web工程时

导入的jar包

1、spring:
  spring ioc
    spring-beans-4.0.0.RELEASE.jar
    spring-context-4.0.0.RELEASE.jar
    spring-core-4.0.0.RELEASE.jar
    spring-expression-4.0.0.RELEASE.jar
    commons-logging-1.1.3.jar
  spring aop
    com.springsource.net.sf.cglib -2.2.0.jar
    com.springsource.org.aopalliance-1.0.0 .jar
    com.springsource.org.aspectj.weaver-1.6.8 .RELEASE.jar
    commons-logging-1.1.3. jar
    spring-aop-4.0.0.RELEASE.jar
    spring-aspects-4.0.0.RELEASE.jar

2、spring mvc
    commons-logging-1.1.3.jar
    spring-aop-4.0.0.RELEASE.jar
    spring-beans-4.0.0.RELEASE.jar
    spring-context-4.0.0.RELEASE.jar
    spring-core-4.0.0.RELEASE.jar
    spring-expression-4.0.0.RELEASE.jar
    spring-web-4.0.0.RELEASE.jar
    spring-webmvc-4.0.0.RELEASE.jar
3、mybatis
    log4j-1.2.17.jar //当然需要注意的是:log4j的jar包是需要log4j.xml文件的
    mybatis-3.4.1.jar 
    mysql-connector-java-5.1.37-bin.jar
4、spring-mybatis
    mybatis-spring-1.3.0.jar
5、其他:
    junit-4.9.jar
    servlet-api-2.5.jar
    jsp-api-2.0.jar
    mysql-connector-java-5.1.37.jar
    c3p0-0.9.2.jar
6、JDBCTemplate:
    spring-jdbc-4.0.0.RELEASE.jar
    spring-orm-4.0.0.RELEASE.jar
7、JSTL:
    taglibs-standard-impl-1.2.5.jar
    taglibs-standard-spec-1.2.5.jar
8、上传下载:
    commons-fileupload-1.3.1.jar
    commons-io-2.4.jar
9、处理Json数据:
    jackson-annotations-2.1.5.jar
    jackson-core-2.1.5.jar
    jackson-databind-2.1.5.jar

三、创建Maven工程时

pom.xml文件中添加jar包

复制代码
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.neuedu.ssm</groupId>
  <artifactId>orm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <dependencies>
        <!-- 测试 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>test</scope>
        </dependency>
        <!-- servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <!-- jsp -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- IOC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <!-- AOP -->
        <dependency>
            <groupId>net.sourceforge.cglib</groupId>
            <artifactId>com.springsource.net.sf.cglib</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.aopalliance</groupId>
            <artifactId>com.springsource.org.aopalliance</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.8</version>
        </dependency>
        <!-- SpringMVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <!-- MyBatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.4.1</version>
        </dependency>
        <!-- Spring整合MyBatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- 数据库连接 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.37</version>
        </dependency>
        <!-- c3p0数据库连接池 -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.2</version>
        </dependency>
        <!-- JDBCTemplate -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <!-- JSTL -->
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-impl</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-spec</artifactId>
            <version>1.2.5</version>
        </dependency>
        <!-- 上传下载 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- 处理Json数据 -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.1.5</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/crm</path>
                    <port>8080</port>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

pom.xml
复制代码
posted on 2018-03-13 12:29  迷之月夜  阅读(219)  评论(0编辑  收藏  举报