ssm框架整合

1、配置文件的分工

  spring配置文件:前端

    一、配置掃描包,排除Controller、ControllerAdvicejava

    二、導入屬性文件mysql

    三、數據庫鏈接池的數據源web

    四、配置事務管理器(datasource屬性)spring

    五、開啓基於註解的事務<tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>sql

    六、配置SqlSessionFactoryBean對象,(dataSource和configLocation屬性)數據庫

    七、配置MapperScannerConfigurer對象(basePackage屬性:mapper包掃描)express

  Spring配置文件applicationContext.xml

  mybatis配置文件:apache

    一、settings的配置api

      配置:數據庫字段轉換爲駝峯式命名

      開啓二級緩存

      開啓懶加載

  MyBatis配置文件mybatis-config.xml

  spring mvc配置文件:

    一、配置掃描包,只掃描Controller、ControllerAdvice

    二、配置視圖解析器InternalResourceViewResolver

    三、配置處理靜態資源文件:<mvc:default-servlet-handler/>

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

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

  Spring MVC配置文件springmvc.xml

  web.xml配置文件:

    一、配置生命週期監聽器ContextLoaderListener,加載IOC容器

    二、配置前端控制器DispatcherServlet

    三、配置字符集過濾器CharacterEncodingFilter

    四、配置Spring MVC過濾器HiddenHttpMethodFilter,使得支持GET、POST、PUT與DELETE請求

  web.xml配置文件

2、建立動態Web工程時

導入的jar包

一、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

二、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
三、mybatis
    log4j-1.2.17.jar //固然須要注意的是:log4j的jar包是須要log4j.xml文件的
    mybatis-3.4.1.jar 
    mysql-connector-java-5.1.37-bin.jar
四、spring-mybatis
    mybatis-spring-1.3.0.jar
五、其餘:
    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
六、JDBCTemplate:
    spring-jdbc-4.0.0.RELEASE.jar
    spring-orm-4.0.0.RELEASE.jar
七、JSTL:
    taglibs-standard-impl-1.2.5.jar
    taglibs-standard-spec-1.2.5.jar
八、上傳下載:
    commons-fileupload-1.3.1.jar
    commons-io-2.4.jar
九、處理Json數據:
    jackson-annotations-2.1.5.jar
    jackson-core-2.1.5.jar
    jackson-databind-2.1.5.jar

3、建立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
複製代碼
相關文章
相關標籤/搜索