the construction of SSM framework--spring+springmvc+mybatis
One: Overview
The SSM framework is often used in project development, and it is applied more broadly in only a few years of development compared to the SSH framework. Spring, as a lightweight framework, has a lot of expansion capabilities, the most important of which is the IOC and AOP used in our general projects. SPRINGMVC is a Web layer implemented by spring, equivalent to the struts framework, but more flexible and powerful than struts. MyBatis is a persistent layer framework that is more flexible to use than hibernate and can control the writing of SQL, using XML or annotations for related configurations.
According to the above description, learning the SSM framework is very important.
II: Build a SSM process using MAVEN to manage projects
Using MAVEN to create a WebApp project in Eclipse, the specific creation process does not demonstrate, as there is no creation of [Create project]
You can also use the MAVEN command to create, enter the specified directory in a DOS window, and execute the following command:
MVN Archetype:create-dgroupid=org.ssm.dufy-dartifactid=ssm-demo-darchetypeartifactid=maven-archetype-webapp- Dinteractivemode=false
Use the command to be aware that the system has MAVEN installed and the environment variable is configured. [MAVEN Installation and environment variable configuration]
Import project (named Creation), add dependency
The import project is in the IDE, or it is created directly in the IDE, with the general default of "Src/main/java" and manually creating the "Src/test/resources", "Src/test/java" folder.
The following project structure:
Then directly configure the package dependencies in the Pom.xml file.
<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/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>org.dufy</groupId> <artifactId>ssm</artifactId> & Lt;packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>ssmdemo</name > <url>http://maven.apache.org</url> <properties> <spring.version>4.0.5.release</sp Ring.version> <mybatis.version>3.2.1</mybatis.version> <slf4j.version>1.6.6</ Slf4j.version> <log4j.version>1.2.12</log4j.version> <mysql.version>5.1.35</ Mysql.version> </properties> <dependencies> <!--Add Spring dependency--<dependency>
; <groupId>org.springframework</groupId> <artiFactid>spring-core</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactid>spring-webmvc&
lt;/artifactid> <version>${spring.version}</version> </dependency> <dependency>
<groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupid& Gt;org.springframework</groupid> <artifactId>spring-context-support</artifactId> <ver sion>${spring.version}</version> </dependency> <dependency> <groupid>org.spring Framework</groupid> <artifactId>spring-aop</artifactId> <version>${spring.version} </version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactid&
Gt;spring-aspects</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactid>spring-tx</arti
factid> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <v ersion>${spring.version}</version> </dependency> <dependency> <groupid>org.spri Ngframework</groupid> <artifactId>spring-web</artifactId> <version>${spring.versio N}</version> </dependency> <!--Spring Unit test dependency--<dependency> <group Id>org.springframeworK</groupid> <artifactId>spring-test</artifactId> <version>${spring.version }</version> <scope>test</scope> </dependency> <!--spring WEBMVC related Jars- <dependency> <groupId>org.springframework</groupId> <artifactid >spring-webmvc</artifactId> <version>${spring.version}</version> </dependency&
Gt <dependency> <groupId>org.springframework</groupId> <artifactid>spring-web </artifactId> <version>${spring.version}</version> </dependency> <!-- MySQL Driver Pack-<dependency> <groupId>mysql</groupId> <artifactid>mysql-connec tor-java</artifactid> <version>${mysql.version}</version> </dependency> <! --Alibaba DATA Source related JAR--<dependency> <groupId>com.alibaba</groupId> <artifacti D>druid</artifactid> <version>0.2.23</version> </dependency> <!--a
Libaba Fastjson Formatted--<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.1.41</version> </DEP
Endency> <!--logback Start-to-<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependen cy> <dependency> <groupId>org.slf4j</groupId> <artifactid>slf4j-api</art
ifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>ch.qos.lOgback</groupid> <artifactId>logback-classic</artifactId> <version>1.1.2</versi on> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <ar tifactid>logback-core</artifactid> <version>1.1.2</version> </dependency> <d Ependency> <groupId>org.logback-extensions</groupId> <ARTIFACTID>LOGBACK-EXT-SPRING&L
T;/artifactid> <version>0.1.1</version> </dependency> <!--mybatis dependency <dependency> <groupId>org.mybatis</groupId> <ARTIFACTID>MYBATIS</ARTIFACTID&G
T <version>${mybatis.version}</version> </dependency> <!--mybatis/spring Package--<depe
Ndency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <vErsion>1.2.0</version> </dependency> <!--add servlet3.0 Core Pack--<dependency> <groupId>javax.servlet</groupId> <artifactid>javax.servlet-api</artifactid>
; <version>3.0.1</version> </dependency> <dependency> <groupid&
Gt;javax.servlet.jsp</groupid> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.2-b01</version> </dependency> <!--jstl-<depen Dency> <groupId>javax.servlet</groupId> <ARTIFACTID>JSTL</ARTIFACTID&G
T <version>1.2</version> </dependency> <!--unit Testing dependent-<dependency> < ;groupid>junit</groupid> <artifactId>junit</artifactId> <version>3.8.1</version><