Spring Boot Reference Tutorial (i) Springboot Overview and Hello World

Source: Internet
Author: User

Objective

I have nothing to do, write this document, shortcomings, Haihan!

This document will detail the sping boot features, how to use them, and the integrated application with third-party frameworks. Enables developers to quickly understand springboot and skillfully use the springboot application in development.

The author will introduce the integrated application of Spring boot and third-party framework, and the solutions used in general development will be embodied in this document.

I write this document will follow the steps of beginners step by step in-depth, easy to learn.

Note that learning Spring BooT requires developing understanding of the spring4.x version and the development use of MAVEN engineering.

The author will provide the relevant tools used in this document, as well as the Demo.

In addition, the author will provide relevant references and related articles used in the document.

I write this article, to record learning Spring boot process encountered problems and record learning experience, but also for interested students as a reference, if there is a little help, it is an honor!

Spring Boot Overview

(a) Before you know spring boot, let's start by saying the traditional spring project:

1. In the process of building a traditional spring project, first create an empty project (or Maven project).

2. Add spring-related jar packages, or spring dependencies (MAVEN engineering), such as spring web.

3. Then configure the Web. xml file in the project, such as Dispatch servlet.

4. Also need to configure in spring configuration files such as Applicationcontex.xml (or xxx-dispatcherservlet.xml) files such as Aop,json Converter, encoder, open agent, turn on component scanning, etc.

5. When you configure a data source, you also need to include the relevant database, the data source, the jar package or dependencies of the persistence framework, and then configure the data source instances, transactions, and so on in the configuration file.

6. In general, any part of the component required to join the project, such as caching, needs to be added to the appropriate jar or dependency and then configured in a cumbersome configuration file.

(b) The shortcomings of the traditional spring project are summarized as follows:

1. You need to add a large number of jar packages or dependencies and handle compatibility issues with different versions of different jar packages.

2. The configuration is cumbersome and requires a lot of configuration.

3. Redundant development time, using spring to develop different projects need to join the jar package or dependency, and the configuration is basically the same, such as open component Scan configuration, configuration AOP, data source, cache, log and so on. Can be called a templated configuration.

4. Configure various instances, the configuration of the instances in different projects is basically the same, and the process of initiating cannot see the initialization process of the instance, nor can you learn more about the initialization success or failure of the concrete instance.

(iii) based on the shortcomings of the traditional spring engineering, Springboot emerged as follows:

Advantages

1. Quickly build a project

2. No configuration integration of the mainstream development framework

3. The project runs independently without the need for external servlet containers

4. Provide run-time application monitoring

5. Greatly improve the efficiency of development deployment

6. Natural integration with cloud computing

The official introduction of Spring boot, this is no longer described here, only the author's own views.

Spring boot is not a new framework, it is a new build project based on the sprig4.x version and Maven, which uses spring to greatly improve development efficiency and enable developers to focus on their business.

Spring boot allows you to quickly build projects that meet the needs of traditional spring engineering with a lot of tedious configuration to implement, using a small amount of not even using a configuration, and adding a small amount of start-up dependencies.

In short, spring boot can be based on a small number of dependencies and a small number of configurations, automatic identification, automatic configuration, automatic initialization of relevant instances. Spring Boot is a "convention greater than configuration", so that developers do not need to manually configure it.

The author uses spring boot development and is not accustomed to use the traditional way of development, especially the popularity of microservices, using spring boot can further learn to use the Spring Cloud microservices framework, if interested can see the author's spring Cloud article.

1. Build Spring Boot Project

The Spring Boot official documentation provides a variety of ways to build the spring boot project, and this article only works with the initial project page provided by the Spring Boot website as a tool for project creation, and for other methods if you are interested in self-study.

1. Visit Http://start.spring.io Fill in the details of the project, tick the required options, examples are as follows:

2. Unzip the Import Spring boot project, the project directory is as follows:

3. View the Pom file:

4. For convenience, two classes can be synthesized into one:

5. Start the project: Run as Java application directly in Class 3:

Start successfully!

6. Test the project, write the test code:

7. to restart the test:

Mapping succeeded

Test Access success

8. Summarize:

(1) Use the Spring boot tool to create a template project, simple and fast.

(2) There are only three dependencies in the automatically created project without any dependencies.

(3) did not do any configuration, such as annotation scanning, configuration controller and so on.

From the above Hello world can first recognize the benefits of Springboot.

The following is a further look at Spring boot features.

< instance code >

Github:https://github.com/chunyuding/springboot-demo

Https://github.com/chunyuding/SpringBoot-Demo.git

Code Cloud: Https://gitee.com/dingchunyu/SpringBoot-Demo

Https://gitee.com/dingchunyu/SpringBoot-Demo.git

< recommended books >

Baidu Cloud: Http://pan.baidu.com/s/1qYA0Nxi

Spring Boot Reference Tutorial (i) Springboot Overview and Hello World

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.