Xiaobaiai.net xiaobaiai.net Xiaobaiai.net xiaobaiai.net

[TOC]

1 Before WE start

Before I started to learn Spring Boot, I had never touched any spring-related projects before. I learned the basics of Java by myself a few years ago, and I think I have almost forgotten them now. Before WRITING my own learning process of Spring Boot, I would like to encourage my classmates to believe that I can learn it well. After roughly understanding the whole development of Spring, there are still a lot of paving knowledge to know, and even if know, without practical experience may not be able to deeply experience the difference in the actual project. In short, just do it, and then stick to it. As for why I want to learn Spring Boot, this is my own choice, a link in the road of architecture, a big move in martial arts, and I look forward to learning this big move. Spring Boot is already the top layer of Spring, from top to bottom, from new to old, through the whole Spring context.

2 Terms

Of course, before learning, you must do some research to understand various terms related to Spring, because there are too many, if you do not understand, it will cause confusion and difficult to understand later learning, especially if you have never touched Java Web. Everything we learn about Spring is ultimately about how to build enterprise-class Web applications better and faster. Here are some of the terms I knew before I started and the functional roles they play.

nomenclature paraphrase
SQL & NOSQL No, Not Only the SQL, non-relational database referred, such as common HBase, BigTable, Redis, Cassandra, LevelDB, directing, CouchDB. SQL here refers to RDBMS, namely relational database management system, such as Oracle,DB2,SQL Server,Mysql and so on
Nginx Nginx is a lightweight Web server, forward/reverse proxy server, load balancing, mail proxy server and generic TCP/UDP proxy server, originally written by Russian Igor Sysoev, BSD licensed. It is widely used in Internet projects because of its small memory footprint, extremely fast startup and high concurrency.
Jetty Jetty can provide Web services independently as a standalone Servlet engine, but it can also integrate with other Web application servers, so it can provide work over two protocols, one HTTP and one AJP. Compared with Tomcat, each has its own characteristics, as a rising star, always with fresh and rapid growth characteristics
Netty Netty is an asynchronous event-driven (NIO, non-blocking IO) network application framework for rapid development of maintainable high-performance protocol servers and clients. Tomcat is based on Http, while Netty supports various protocols and custom protocols, including Http, Websocket, SSL&TLS, Protobuf, RTSP, Zlib&gzip, LFS, etc. Netty is a network programming framework that is easy to customize, as is MINA
Undertow Undertow is a flexible, high-performance Web server written in Java that provides NIO based blocking and non-blocking apis. The same supports Http and Websocket protocols
JDBC Java DataBase Connectivity is a Java API for executing SQL statements that provides unified access to multiple relational databases. It consists of a set of classes and interfaces written in the Java language.
JPA JPA is a Java persistence specification released with Java EE 5, which provides Java developers with an object/association mapping tool to manage relational data in Java applications. It appears mainly to simplify the existing persistence development work and integrate ORM technology, ending the current situation of Hibernate, TopLink, JDO and other ORM frameworks operating separately.
Servlet At the code level, a Servlet is actually an interface that defines a set of specifications for handling network requests. All classes that implement a Servlet need to implement its five defined methods. By definition, it is a set of Java EE specifications, and Tomcat & Jetty are both containers for carrying servlets
MyBatis MyBatis is an excellent persistence layer framework. MyBatis is an upgraded version of iBatis that supports customized SQL, stored procedures, and advanced mapping. MyBatis avoids almost all of the JDBC code and manual setting of parameters and fetching result sets. MyBatis can use simple XML or annotations to configure and map native types, interfaces, and Java’s Plain Old Java Objects (POJOs) to records in the database. The latest version is 3.5.3
Hibernate Hibernate is an ORM framework, called Object Relative DateBase Mapping, which establishes some mappings between Java objects and relational databases to achieve direct access to Java objects. The latest version of Hibernate ORM is 5.4.7
struts2 Apache Struts is a free open source MVC framework for creating elegant modern Java Web applications. It supports convention over configuration, can be extended using a plug-in architecture, and comes with plug-ins that support REST, AJAX, and JSON. The latest version is 2.5.20
Struts Spring Hibernate(SSH) SSH framework is composed of struts2, Spring and Hibernate. The core idea of Struts is to implement MVC; The core idea of Spring is decoupling, that is, there is no new implementation class in the code, we create the interface and we don’t care who the implementation class is; The core idea of Hibernate is to connect to the database (ORM-object relational mapping), so we don’t have to write statements to create tables in the database
Spring An open source framework that provides end-to-end support for response-based and servlet-based applications on the JVM, using basic Javabeans instead of EJBs. Is a popular framework for creating Java enterprise applications. It has moved beyond the original product to encompass the entire family of projects that use and build around the Spring framework. Spring’s core technologies are dependency injection (DI), events, resources, I18N, validation, data binding, type conversion, SpEL, and AOP. The Spring framework is now 5.0
Spring MVC Spring MVC is a loosely coupled MVC framework. It is one of the many components of the Spring framework that enables you to implement Web applications according to the model-View-controller design pattern. Struts is tightly coupled. For enterprise applications, you need to build loosely coupled applications because it makes them more reusable, robust, and distributed.
Spring WebFlux Is a new module in Spring5, developers can use WebFlux to create high-performance Web applications and clients, the name of the Flux is derived from the Reactor class Flux, The module includes client and server support for reactive HTTP, server push events, and WebSocket. In server-side development, WebFlux supports two different programming models: the first is the Java annotation-based approach used in Spring MVC; The second is a functional programming model based on Java 8’s lambda expressions
Spring Cloud Spring Cloud provides tools for developers to quickly build certain common patterns found in distributed systems (e.g., configuration management, service registration and discovery, circuit breakers, intelligent routing, micro-proxies, control buses, one-time tokens, global locks, leadership elections, distributed sessions, cluster state, load balancing). Microservices architecture integrator, cloud computing best business practices. Spring Cloud is implemented based on Spring Boot and uses HTTP RESTful apis as the invocation method. It consists of multiple sub-projects that work together to build microservices architecture. Overall, Spring Cloud is richer and better than Dubbo in terms of community and ecology, but the cost of learning is higher than Dubbo
Dubbo Alibaba opened source in 2011, stopped updating in 2013, but restarted maintenance and released a new version in September 2017. Dubbo uses Zookeeper as the registry and RPC as the service invocation method, and is committed to providing high-performance and transparent RPC remote service invocation solution. It integrates seamlessly with Spring, builds a simple model based on the roles of service provider (server) and service caller (client), and has the advantage of being easy to use and low cost to learn
Spring Cloud Data Flow Connecting businesses to the Internet of Things — mobile devices, sensors, wearables, cars, and more. Spring Cloud Data Flow provides a unified service for creating composable Data microservices that address both Flow and ETL based Data processing patterns.
Reactive stack & Servlet stack Spring5 offers two Web technology stacks, Servlet and reactive, that are sufficiently close to asynchronous and non-blocking concurrency at the application level.
Micro service Microservice is a distributed system architecture, an idea and a design principle. Spring Cloud is the mainstream scheme for developing microservices, and Spring Boot takes Spring Cloud as its core, which makes issuing microservices faster and more convenient. The development of micro-service frameworks include Netflix OSS(the originator of micro-service practice), Dubbo, gRPC, etc
Service Mesh The infrastructure layer of communication between services, which can be likened to TCP/IP between applications or microservices, is responsible for network calls, traffic limiting, fuses, and monitoring between services. Related open source Service Mesh projects include Linkerd, Envoy, Istio, Conduit, nginMesh, Kong, etc. Compared with microservices, microservices are more like an ecosystem between services, focusing on Service governance and other aspects, while Service grids are more focused on communication between services. And better integration with DevOps

There are a lot of concepts, but basically refers to the concept of a large software framework, each of which can be extended a lot of knowledge, see the reference links for more details. But this is just the beginning, you can gradually understand, and in the field to understand each term has its own characteristics.

3 Spring Boot features and advantages and disadvantages

Now that I’ve chosen to start from the top down and take the old and new approach, we need to know more about Spring Boot and what role it plays in the overall technology stack.

The slogan of Spring Boot is BUILD ANYTHING WITH Spring Boot.

As you can see from the component diagrams on the official website, Spring Boot is a large container that is the entry point for building all Spring-based applications. Spring Boot is designed to get projects up and running as quickly as possible with minimal Spring upfront configuration. For example, the biggest advantage of Spring Boot compared to Spring MVC is that it is easy to use, convention is more than configuration, and you don’t get confused by XML configuration files as you did before using Spring MVC. Spring Boot is not at the heart of what we’re building Web applications for, and you can get a quick start on Spring Boot, but you can use this portal to see what it’s all about. We can list the features of Spring Boot:

  • You can useSpring InitializrGet started quickly in seconds
    • throughSpring Initializr(https://start.spring.io/), we can quickly build a Spring Boot project based on Web UI
  • Build output for anything: REST apis, WebSockets, Web, streams, tasks, etc
    • Anyway, Web related!
  • Simplify security policy integration
  • Very friendly support for SQL and NoSQL
  • Supports in-run containers: Tomcat, Jetty, and Undertow
    • Very easy to develop and test our Web application
  • Developers produce tools such as LiveReload and Auto Restart
  • Automatic version dependency management
    • Avoid writing a lot of boilerplate code, comments, and XML configurations.
  • Functions that can be used for production, such as tracking, metrics, and health
  • Use your preferred IDE, such as Spring Tool Suite(STS), IntelliJ IDEA(IDEA), or NetBeans
  • It provides CLI (command line interface) tools that can be developed and tested from the command prompt very easily and quicklySpring Boot(Java or Groovy) application
  • Many plug-ins are provided
    • Spring Boot applications can be developed and tested very easily using build tools such as Maven and Gradle
    • It is very easy to work with embedded and in-memory databases

With the above features, what benefits or limitations can Spring Boot bring me?

  • Spring is donepackaging, making it easy to understand and develop Spring applications and simplify configuration, testing, packaging, and integration with third-party tools
  • Quickly configure projects, manage dependent versions, quickly configure unit tests, integration tests, etc., improve development efficiency and productivity
  • Can only solve problems likeSpring FrameworkIs unable to solve the new problem, i.eSpring FrameWorkWhat can be done can be done
  • Will be the existing or old versionSpring FrameworkProject conversion toSpring BootApplications can be taxing

4 summarizes

In this article, we will start from scratch and discuss some of Spring Boot’s features, advantages and disadvantages. Through the elaboration of Spring Boot, let us have a basic understanding of it, next, we start to enter the interior of Spring Boot and actual combat.

5 more

For more information about Spring Boot, please continue to follow my official account Xiaobaiai or wechat small program Xiaobaiai blog or PC side website xiaobai.net.

6 Reference Materials

  • https://nginx.org/en/
  • https://www.jianshu.com/p/296bacba3510
  • https://www.ibm.com/developerworks/cn/java/j-lo-jetty/index.html
  • https://www.ibm.com/developerworks/cn/opensource/os-cn-spring-jpa/index.html
  • https://netty.io/
  • https://stackoverflow.com/questions/6719004/understanding-servlet-container
  • https://mybatis.org/mybatis-3/
  • https://hibernate.org/orm/what-is-an-orm/
  • https://struts.apache.org/
  • https://spring.io/
  • https://docs.spring.io/spring-boot/docs/current/reference/html/
  • https://start.spring.io/
  • https://spring.io/projects/spring-framework
  • https://www.ibm.com/developerworks/cn/java/spring5-webflux-reactive/index.html
  • https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#spring-webflux
  • https://spring.io/projects/spring-cloud
  • https://www.springcloud.cc/
  • https://zhuanlan.zhihu.com/p/36182136
  • https://www.infoq.com/articles/Servlet-and-Reactive-Stacks-Spring-Framework-5/
  • http://www.reactive-streams.org/
  • https://medium.com/clover-platform-blog/building-a-microservice-with-spring-boot-and-spring-cloud-1c8275d7d229
  • https://jimmysong.io/posts/what-is-a-service-mesh/
  • https://istio.io/

    This article belongs to the original, reprint the source, welcome to pay attention to wechat small programSmall white AI blogWechat official accountThe small white AIOr websitexiaobaiai.net