SSM framework-Detailed Integration tutorial (Spring+springmvc+mybatis+maven)

Source: Internet
Author: User
Tags log4j

Using SSM (Spring, SPRINGMVC, and MyBatis) has been around for three months, the project has no technical difficulties, based on the existing technology can achieve the desired function, of course, there are certainly a lot of areas to improve. The process of SSM integration was not documented before, and it was just a good time to build a new project based on one of its own, and better than the project. The previous problem solving process and methods are not recorded in time, later in their own small project encountered me to organize and share. This time, let's talk about the three framework integration process. Personally, the use of frames is not difficult, the key to understand their ideas, which is very helpful for us to improve the level of programming. However, if you do not use it, talk about thinking becomes a theory ... First technology, then thought. Practice is the real truth. (The blog address can be viewed via image watermark)


1. Basic Concepts
1.1. Spring

Spring is an open source framework, and spring is a lightweight Java development framework that emerged in 2003 by Rod Johnson in his book expert one-on-one development and Some of the concepts and prototypes elaborated in design are derived. It is created to address the complexities of enterprise application development. Spring uses basic JavaBean to accomplish things that were previously only possible by EJBS. However, the use of spring is not limited to server-side development. From the standpoint of simplicity, testability, and loose coupling, any Java application can benefit from spring. In short, spring is a lightweight control inversion (IoC) and aspect-oriented (AOP) container framework.


1.2, Springmvc

Spring MVC is a follow-on product of springframework and has been integrated into spring Web flow. Spring MVC separates the roles of controllers, model objects, dispatchers, and handler objects, and this separation makes them easier to customize.


1.3, MyBatis


MyBatis is an open source project for Apache Ibatis, which was migrated to Google code by the Apache Software Foundation in 2010 and renamed MyBatis. MyBatis is a Java-based persistence layer framework. The persistence layer framework provided by Ibatis includes SQL maps and Data Access Objects (DAO) MyBatis eliminates the manual setting of almost all JDBC code and parameters and the retrieval of result sets. MyBatis uses simple XML or annotations for configuration and raw mapping, mapping interfaces and Java POJOs (Plain old Java Objects, ordinary Java objects) to records in a database.



2. Construction of development environment



If necessary, see the previous blog post: http://blog.csdn.net/zhshulin/article/details/30779873



3. Maven Web project Creation

If necessary, see the previous blog post: http://blog.csdn.net/zhshulin/article/details/37921705



4. SSM Integration

The following is mainly about the integration of the three frameworks, as for the construction of the environment and the creation of projects, see the above blog post. I've divided 2 profiles for this integration, The Spring-mybatis.xml, which contains the spring and MyBatis profiles, and a configuration file for Spring-mvc, plus 2 resource files: Jdbc.propertis and log4j.properties. The full directory structure is as follows (finally attached source download address, not recommended to use the source code directly, because this tutorial already has all the codes):

The use of frames is a newer version:

Spring 4.0.2 RELEASE

Spring MVC 4.0.2 RELEASE

MyBatis 3.2.6
4.1. Maven introduces the required jar package

In order to make it easier to say later without the need to introduce the jar package, I am here to give all the necessary jar package, this is the basic jar package, each package is what the comment, no longer say.

Pom.xml

[HTML]  View plain  copy  print? <properties>           <!-- spring version number  -- >           <spring.version>4.0.2.release</ spring.version>           <!-- mybatis version number  -- >           <mybatis.version>3.2.6</ mybatis.version>           <!-- log4j log File Management Pack version  -->           <slf4j.version>1.7.7</ slf4j.version>           <log4j.version>1.2.17</ log4j.version>       </properties>           <dependencies>           <dependency>               <groupId> Junit</groupid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.