How to build the Spring Boot Framework (Notes)

Source: Internet
Author: User

I. Spring boot history background

Spring was born as a lightweight alternative to the Java Enterprise Edition (Java Business Edition,jee, also known as EE). Without the development of heavyweight Enterprise JavaBean (EJB), Spring provides a relatively simple way for enterprise Java development, with dependency injection and aspect-oriented programming, with simple Java objects (Plain old Java object, POJO) implements the functionality of the EJB. Although Spring's component code is lightweight, its configuration is heavyweight.

The 3 times of Spring:

First stage: XML Configuration >> in the Spring 1.x era, using spring to develop an eyeful of XML configuration beans, as the project expands, the XML configuration file needs to be placed in a different configuration file, then need to frequently switch between the developed classes and configuration files

Second stage: annotation configuration >> in the Spring 2.x era, with the annotations supported by JDK1.5, Spring provides annotations for declaring beans (such as @controller, @Service), greatly reducing the amount of configuration. The main use is the basic configuration of the application (such as database configuration) with XML, business configuration with annotations

Phase III: Java Configuration >>spring 3.0 introduces Java-based configuration capabilities, a type-safe, reconfigurable configuration that can be used in place of XML. We are just in this time now. The Java configuration is now recommended for both Spring and Springboot.

Summary : All configurations represent loss at the time of development. Because of the need to switch between thinking about the Spring feature configuration and solving business problems, the write configuration is crowding out the time to write application logic. In addition, the project's dependency management is a thankless task. Deciding which libraries to use in your project is already a headache, and it's tricky to know which version of these libraries will not conflict with other libraries. Also, dependency management is a loss, and adding a dependency is not a write application code. Once you choose the wrong version of the dependency, the resulting incompatibility will undoubtedly be a productivity killer.

two. Spring Boot overview

Spring Boot is a set of microservices frameworks based on the spring framework. In essence, spring boot is not a framework, it is a collection of libraries, and a MAVEN or Gradle project imports the appropriate dependencies to use Spring Boot, and does not have to manage the versions of these libraries yourself. In the Distributed Application system of service-oriented development, each business is divided into sub-business system, and Spring Boot provides great convenience for developing these micro-sub-business systems. Help developers create spring-based applications and services more easily, enabling existing and new spring developers to get the spring functionality they need the most quickly.

Advantages: Spring Boot has made this all the past. Spring Boot simplifies spring-based application development and requires "run" to create a standalone, production-level spring application. Spring Boot provides the spring platform and third-party libraries with out-of-the-box settings (with default settings) so that we can start simple. Most spring Boot applications require only a small spring configuration. We can use Spring boot to create a Java application and launch it using Java–jar, or with a traditional war deployment method.

disadvantage: After packaging, modify the content of the project is not convenient only the overall update; If you encounter a component that is not officially supported by spring boot, it must be cumbersome to manually integrate.

three. The dependencies that Spring Boot needs to use
<dependency> <groupId>org.springframework.boot</groupId> <artifactId> Spring-boot-starter-web</artifactid> </dependency>
four. Getting Started demo
 //write a boot class 
@SpringBootApplication Public class application { public static void main (string[] args) {springapplication.run (application. ) class
// Write a processor class @RestController  Public class Helloworldcontroller {@GetMapping ("/info"publicreturn "Hello world!" ; }}
// Create a resource profile, application.properties, to modify the Tomcat boot port  8080server.port=8888

Launch boot class, browser access: Localhost:8888/info

How to build the Spring Boot Framework (Notes)

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.