SSM Framework Set -01-detailed introduction-Getting Started issues

Source: Internet
Author: User
Tags java se

SSM Framework Set -01-detailed introduction-Getting Started issues

Beginning to understand SSM, first solve several basic problems

1. What is the SSM framework set?

    • The SSM (Spring+springmvc+mybatis) frameset is a combination of the spring, MyBatis two open source frameworks (Springmvc is part of spring). A framework for Web projects that are often simpler than data sources.
    • SSM is the standard MVC pattern, dividing the entire system into presentation layers, controller layers, service layers, and DAO layer four layers. Use spring MVC for forwarding and view management of requests. Spring implements business object management, MyBatis as a persistence engine for data objects.
    • If the novice may not know from the beginning of what to start learning, first understand the two parts of learning big Spring,mybatis, it is recommended to learn spring first, you can go to W3cschool Spring Tutorial, and then learn MyBatis, you can learn in the MyBatis official website document. Then I will always be on the blog to update the study notes, learn together

2. What is Spring?

    • Spring is an open source lightweight Java SE (Java Standard Version)/java EE (Java Enterprise Edition) Development application framework designed to simplify enterprise application development. An application consists of a set of objects that work together. In traditional application development, a complete application consists of a set of mutually collaborative objects. So, in addition to developing business logic, the most common way to develop an application is to focus on how to make these objects work together to accomplish the required functionality, and to be low-coupled and high cohesion. Business logic development is unavoidable, if there is a framework to help us create objects and manage the dependencies between those objects. It may be said that, for example, "abstract factory, factory method design pattern" Can not help us to create objects, "generator mode" to help us to deal with the dependencies between objects, can not do these functions? But these need us to create another factory class, generator class, we have to manage these classes, add our burden, if we can have a configuration to create objects, to manage the dependencies between objects, we do not need to through the factory and generator to create and manage the dependencies between objects, So do we reduce a lot of work, speed up development, and save a lot of time to do other things. The spring framework came out primarily to complete this function.
    • In addition to helping us manage objects and their dependencies, the spring framework also provides facets-oriented capabilities like general-purpose logging, performance statistics, security controls, exception handling, and also helps me manage the most headaches of database transactions, providing a simple JDBC access implementation. Provides integration with third-party data access frameworks (such as Hibernate, JPA), integration with various Java EE technologies (such as Java Mail, task scheduling, and so on), provides a set of its own web-tier framework, spring MVC, and is also very simple to integrate with third-party web frameworks. From here we can think of spring as a super-bonding platform that, in addition to its own functionality, provides the ability to glue other technologies and frameworks, giving us a freer choice of what technology to use for development. And whether it's Java
      Either the SE (c/S architecture) application or the Java EE (b/S architecture) application can be developed using this platform. Let's take a closer look at what spring can do for us.

What can 3.Spring do for us?

Not only does spring help us write business logic, but almost anything else can help us simplify our development:

  • (1) Traditional program development, the creation of objects and the dependencies between objects are controlled within the program, which will increase the coupling between the various objects, if we want to modify the dependencies between objects must modify the source code, recompile, deployment, and if the use of spring, By spring, the dependencies between objects are created and assembled based on the configuration file, and only the configuration files need to be changed without recompiling. So, spring can help us create and assemble dependencies between objects based on the configuration file.
  • (2) When we want to do some logging, permission control, performance statistics, etc., in the traditional application we may be in need of objects or methods, and such as permission control, performance statistics are mostly duplicated, so there is a lot of code duplication code, even if some people say I extract the generic part, There must be a call or a repetition, like performance statistics we may only do when necessary, after the diagnosis to remove the code, as well as log records, such as logging some methods access logs, data access logs, and so on, which will permeate the various access methods, as well as permission control, It must be reviewed at the beginning of the execution of the method to think about how horrible and boring the work is. With spring, these logging, permission control, and performance statistics are separated from the business logic, and are dynamically added to the required features by spring-supported aspect-oriented programming, without penetrating into the various methods or objects required; One might say that we can use the " Proxy design mode "or" Wrapper design pattern "You can use these, but still need to programmatically create proxy objects, or to coupling these proxy objects, and the use of spring-oriented programming can provide a better way to accomplish the above functions, generally through configuration, and without adding any extra code to the existing code, the existing code focuses on the business logic. Therefore, Spring aspect-oriented programming can help us to realize the non-coupled implementation of logging, performance statistics, security control.
  • (3) In traditional applications, how do we manage database transactions? Requires a series of "Get the connection, execute SQL, commit or rollback the transaction, close the connection", but also make sure to close the connection at the end, what a horrible thing, but also very boring; if we take spring, we just need to get the connection, execute the SQL, and all the rest to spring to manage, simple. So, spring can help us manage database transactions very simply.
  • (4) Spring also provides seamless integration with third-party data access frameworks such as Hibernate, JPA, and provides a JDBC access template to facilitate database access.
  • (5) Spring also provides seamless integration with third-party web frameworks such as struts, JSF, and provides a spring MVC framework to facilitate web-tier building.
  • (6) Spring can be easily integrated with Java EE (such as Java Mail, Task Scheduler) and more technology integration (such as caching framework).

  • Spring can help us do so many things, to provide so many functions and integration with so many mainstream technology, but also to help us do the development of more headaches and difficult things, it may be asked, there is only spring this framework, there is no other choice? Of course, such as EJB needs to rely on application server, development efficiency is low, in the development of small and medium-sized projects are slaughter chicken sledgehammer, although the development of the EJB is now more useful, but still more cumbersome to rely on application server and so on.

4. What is SPRINGMVC?

    • SPRINGMVC is part of Spring, and Springmvc separates the roles of controllers, model objects, dispatchers, and handler objects, which makes them easier to customize.
    • The problem with many applications is that there is a tight coupling between the object that handles the business data and the view that displays the business data, and typically, the commands that update the business object are initiated from the view itself, making the view highly sensitive to any business object changes. Also, there is no flexibility when multiple views depend on the same business object.
    • SPRINGMVC is a Java-based implementation of the Web MVC design pattern, the request-driven type of lightweight web framework, that is, the idea of using the MVC architecture pattern, the Web layer to the responsibility of decoupling. Request-driven is the use of the request-response model, the purpose of which is to help us simplify our development, and SPRINGMVC to simplify our daily web development

5. What is MyBatis?

    • MyBatis is an excellent persistence layer framework that supports custom SQL, stored procedures, and advanced mapping. MyBatis avoids almost all JDBC code and manually sets parameters and gets the result set. MyBatis can use simple XML or annotations to configure and map native information, mapping interfaces and Java POJOs (Plain old Java Objects, ordinary Java objects) to records in a database

6. Why use MyBatis?

    • Easy to learn: it's small and simple. No third-party dependencies, the simplest installation as long as two jar files + configuration of several SQL mapping files easy to learn, easy to use, through the documentation and source code, you can compare the complete grasp of its design ideas and implementation.
    • Flexible: MyBatis does not impose any impact on the existing design of an application or database. SQL is written in XML to facilitate unified management and optimization. With SQL you can basically implement all the features that we can do without using the data access framework, perhaps more.
    • Decoupling SQL from program code: By providing a DAO layer that separates business logic from data access logic, the system is designed to be clearer, easier to maintain, and easier to unit test. The separation of SQL and code improves maintainability.
    • Provides mapping label, supports ORM field relationship mapping between object and database, provides object relational mapping tag, supports object relationship building maintenance, provides XML tags, supports writing dynamic SQL.

More Articles Links: SSM Framework Set

SSM Framework Set -01-detailed introduction-Getting Started issues

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.