Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between SpringCloud and SpringBoot?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the difference between SpringCloud and SpringBoot, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

One. SpringBoot

1. Brief introduction

Spring Boot is a new framework provided by the Pivotal team, which is designed to simplify the initial building and development process of new Spring applications. The framework is configured in a specific way so that developers no longer need to define a templated configuration. In this way, Spring Boot is committed to becoming a leader in the booming field of rapid application development (rapid application development).

SpringBoot is a new open source lightweight framework developed by the Pivotal team in 2013 and released in April 2014. Based on Spring4.0 design, it not only inherits the excellent features of Spring framework, but also further simplifies the whole construction and development process of Spring application by simplifying configuration. In addition, SpringBoot solves the problems of version conflicts of dependent packages and instability of references by integrating a large number of frameworks.

Spring framework is an open source application framework on the Java platform, which provides containers with control inversion characteristics. Although the Spring framework itself has no restrictions on the programming model, its frequent use in Java applications made it so popular that it was later used as a supplement or even a replacement to the EJB (EnterpriseJavaBeans) model. Spring framework provides a series of solutions for development, such as making use of the core features of control inversion and realizing control inversion through dependency injection to realize the containment of the life cycle of management objects, declarative transaction management using aspect-oriented programming, integrating a variety of persistence technologies to manage data access, providing a large number of excellent Web frameworks to facilitate development, and so on. The Spring framework has the feature of IOC. IOC is designed to facilitate project maintenance and testing. It provides a unified method to configure and manage Java objects through the reflection mechanism of Java. The Spring framework uses containers to manage the life cycle of objects. Containers can configure objects by scanning XML files or specific Java annotations on classes, and developers can obtain objects through dependency lookup or dependency injection. Spring framework has aspect-oriented programming (AOP) framework, SpringAOP framework is based on proxy pattern and can be configured at runtime; AOP framework is mainly modularized for cross-concerns between modules. The AOP framework of the Spring framework only provides basic AOP features, which can not be compared with the AspectJ framework, but it can also meet the basic needs through the integration with AspectJ. The functions of transaction management and remote access under Spring framework can be realized by using SpringAOP technology. Spring's transaction management framework brings an abstract mechanism to the Java platform that enables local and global transactions as well as nested transactions to work with Savepoints and work in almost any environment of the Java platform. Spring integrates a variety of transaction templates, the system can configure transactions through transaction templates, XML or Java annotations, and the transaction framework integrates functions such as message passing and caching. Spring's data access framework solves common difficulties that developers encounter when using databases in applications. It not only supports all popular data access frameworks such as Java:JDBC, iBATS/MyBATIs, Hibernate, Java data objects (JDO), ApacheOJB and ApacheCayne, but also can be used with Spring transaction management, providing a flexible abstraction for data access. At first, the Spring framework did not intend to build its own WebMVC framework, and its developers thought that the separation between the presentation layer and the request processing layer of the existing StrutsWeb framework, as well as between the request processing layer and the model was not enough, so they created SpringMVC.

two。 Characteristics

The characteristics of SpringBoot are:

(1) you can create independent Spring applications, and based on their Maven or Gradle plug-ins, you can create executable JARs and WARs

(2) embedded Servlet containers such as Tomcat or Jetty

(3) provide automatic configuration of "starter" Project object Model (POMS) to simplify Maven configuration

(4) configure Spring containers automatically as much as possible

(v) provide ready features, such as indicators, health checks, and externalized configurations

(6) there is absolutely no code generation and no XML configuration is required.

3. Important strategy

There are also two very important strategies in the SpringBoot framework: out of the box and convention over configuration. Out of the box, Outofbox refers to managing the life cycle of objects by adding related dependency packages to the pom file of the MAVEN project during development, and then using corresponding annotations instead of tedious XML configuration files. This feature allows developers to get rid of complex configuration work and dependent management work, and focus more on business logic. Convention is better than configuration. Convention over configuration is a software design paradigm in which the target structure is configured by SpringBoot itself and developers add information to the structure. This feature reduces some flexibility and increases the complexity of BUG positioning, but reduces the number of decisions developers need to make, reduces a large number of XML configurations, and automates code compilation, testing, and packaging.

The basic architecture design of SpringBoot application development template is explained from the front end to the background: the front end often uses template engines, mainly FreeMarker and Thymeleaf, which are written in Java language, rendering the template and outputting the corresponding text, which makes the interface design and application logic separate. at the same time, the front-end development will also use Bootstrap, AngularJS, J Query, etc.; in the browser data transmission format using Json, non-xml, while providing RESTfulAPI The SpringMVC framework is used to process requests after the data arrives at the server; to the data access layer, there are mainly persistent layer frameworks such as Hibernate, MyBatis, JPA, etc. IntelliJIDEA is recommended by common database MySQL; development tools.

4. Core principle

The core principle of SpringBoot is to implement SpringBoot framework based on SpringMVC fully annotated without configuration file + built-in Tomcat, and start with Main function.

Two. SpringCloud

1. Brief introduction

Spring Cloud is an ordered collection of frameworks. It makes use of the development convenience of Spring Boot to skillfully simplify the development of distributed system infrastructure, such as service discovery registration, configuration center, message bus, load balancing, circuit breaker, data monitoring and so on. It can be started and deployed with one button with the development style of Spring Boot. Spring Cloud does not repeat manufacturing wheels, it just combines the more mature service frameworks developed by various companies and withstands the actual test, and shields the complex configuration and implementation principles through Spring Boot style re-encapsulation, and finally leaves a set of distributed system development toolkits that are easy to understand, easy to deploy and easy to maintain for developers.

SpringCloud is a global micro-service coordination governance framework, which integrates and manages individual micro-services developed by SpringBoot to provide integrated services such as configuration management, service discovery, circuit breakers, routing, and so on.

SpringBoot does not depend on SpringCloud,SpringCloud, depends on SpringBoot, and belongs to dependency relationship.

two。 Characteristics

Advantages:

1) the granularity of service splitting is finer, which is conducive to the reuse of resources and improve the efficiency of development.

2) the optimized service scheme can be formulated more accurately and the maintainability of the system can be improved.

3) Micro-service architecture adopts the idea of decentralization, and lightweight communication such as Restful is used between services, which is lighter than ESB.

4) suitable for the Internet era, the product iteration cycle is shorter.

Disadvantages:

1) too many micro-services and high governance costs, which is not conducive to the maintenance of the system.

2) the high cost of distributed system development (fault tolerance, distributed transactions, etc.) is a great challenge to the team.

Generally speaking, the advantages outweigh the disadvantages. At present, SpringCloud is a very perfect distributed framework. At present, many enterprises begin to use micro-services.

3. Common components

The main components involved in SpringCloud include:

1) Eureka: service registry for managing services (registration, discovery of services)

2) Ribbon: load balancing, which is used to build a cluster environment. (if multiple tomcat are configured for the same feature, the load balancer will select one of the multiple tomcat)

3) Hystrix: fuse, disconnected from the main body, use alternative scheme. It can prevent the avalanche effect of service.

4) Feign: service invocation / remote invocation, calling between services, similar to HttpClient

5) Zuul: service gateway, which is used to unify program entry, facilitate management, and provide functions such as route forwarding and request filtering.

4. Core principle

To learn more about SpringCloud, you can visit the following

Three. Difference

SpringBoot and SpringCloud have the following differences:

1) SpringBoot focuses on the rapid and convenient development of individual micro services.

2) SpringCloud is a global micro-service coordination governance framework, which integrates and manages individual micro-services developed by SpringBoot to provide integrated services such as configuration management, service discovery, circuit breaker, routing, micro-agent, event bus, global lock, selected decision, distributed session and so on.

3) SpringBoot can develop independently without SpringCloud, but SpringCloud cannot be developed without SpringBoot and belongs to a dependency relationship.

4) SpringBoot focuses on the rapid and convenient development of individual micro-services, while SpringCloud focuses on the overall service governance framework.

This is the knowledge Xiao Meow is going to share today.

A small interview question is attached at the end:

What is SpringBoot? What is SpringCloud? What's the difference between the two?

1) springboot is a rapid development framework that focuses on the rapid and convenient development of individual micro-services.

Why is the rapid development framework: it is a framework serving the spring framework, it simplifies the configuration file, you can quickly build web applications, built-in tomcat, do not need to package deployment, run directly.

Core principle: based on SpringMVC no configuration file fully annotated + built-in tomcat to achieve SpringBoot framework, using Main function to start.

2) SpringCloud is a global micro-service coordination governance framework, which integrates and manages individual micro-services developed by SpringBoot to provide integrated services such as configuration management, service discovery, circuit breaker, routing, etc.

3) SpringBoot does not depend on SpringCloud,SpringCloud, depends on SpringBoot, and belongs to the dependency relationship.

About what is the difference between SpringCloud and SpringBoot to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report