编程知识 cdmana.com

Spring cloud 2020.0.0 officially released, goodbye Netflix

Share 、 grow up , Refuse to hide and stop . Official account 【BAT The Utopia of 】, Reply key special column Yes Spring Technology stack 、 Middleware and other small and beautiful Original column For free study . This article has been https://www.yourbatman.cn Included .

Preface

Hello , I am a YourBatman.

Beijing time. 2020-12-22 Late at night ,Spring Cloud 2020.0.0 Official release .2020.0.0 Is the first to use the new version of the scheme Spring Cloud Release version .

A few words about the version number : before this ,Spring Cloud Of Release Train The name is London underground station , Such as :Hoxton、Greenwich etc. .

explain :2020.0.0 Version is also known as Ilford( The name of the subway station ), Because of this project 3 It was only a month later that it changed its name according to the new rules , I guess it's for the convenience of communication within the team , You can also understand that it is just an internal code , Easy to communicate

Though arranged in alphabetical order , But there are still two fatal problems :

  • For non English mother tongue Country ( Like the Chinese dynasty ) Very unfriendly , Can't quickly sort out the version number relationship
  • A-Z, If the version number reaches Z What about it ? How to continue to develop ? Your products , Your delicacies

Spring The team realized that this was really a problem , So this year 3 The month made change . For details, please refer to an article I wrote earlier ( Strongly recommended Everyone who comes in knows about this rule change ):Spring Change the naming rules of version number : This is very friendly to non English speaking countries

explain : The version number rule change applies to all Spring Technology stack , contain Spring Framework、Spring Boot、Spring Cloud、Spring Data...

The text goes back to the truth .Spring Cloud As early as the beginning of the year started the development of this version , And this year 4 It was released in January 2020.0.0-M1 edition ( The first milestone version ), Until you leave 2020 It's not the end of the year 10 It's been a long time “ Suffocate ” Big recruit , formal RELEASE.

Spring Cloud As built on Spring Boot Cloud computing framework on top of , I think there are two main reasons for this dystocia :

  1. Spring Boot 2.4.0 edition 2020-11-12 It's only formal RELEASE(Spirng Framework 5.3.0 edition 2020-10-27 only RELEASE)
    1. Spring Framework 5.3.0 Official release , Continue to make efforts on the road of Yunyuan
    2. Spring Boot 2.4.0 Official release , New configuration file loading mechanism ( Not downward compatible )
  2. The changes are really too big , Research and development 、 test 、 The amount of documentation is huge

from Spring Framework、Spring Boot、Spring Cloud The release circuit diagram of the three verified my words once again : You are right about Spring Cloud Knowing more about comes from your understanding of Spring Boot How well do you know , You are right about Spring Boot Knowing more about comes from your understanding of Spring Framework How well do you know . That's why I spend a lot of time on Spring Framework Up, not Spring Boot The root cause is , The bottom is clear , It's easy to use at the top .

Version conventions

  • Spring Framework:5.3.2
  • Spring Boot:2.4.1
  • Spring Cloud:2020.0.0
    • The above version is SC“ carry ” Version of

Text

There's an interesting phenomenon , Before the deadline (2020-12-23 22:00:00) Official website The latest version is not synchronized 2020.0.0 edition ( Pictured ):

In fact as early as 24h Before the official blog made a release announcement :

also Maven Central warehouses also exist, the latest Jar package ( Prove that you're normal 、 It's OK to use it ):

Actually , The document level is not only the official website, but also this one sync The latest version , I'm not going to list them all , After all, it's not very important . In view of this phenomenon, I yy once , Is it right? Spring Cloud There's a shortage of people in the team ? May I ask if there is any social recruitment ?O(∩_∩)O ha-ha ~

Spring Cloud version management

Version management is too important for software development , stay Spring Boot Prior to the emergence of dependency 、 Version management is really big ( Even if there is Spring BOM There is ), Especially when there's a version Maladjustment It's easy to steal an afternoon or even a whole day .

Spring Cloud As the upper application framework , Only when the underlying version is matched can it be normal work, One of the most important is with Spring Boot The version number should be aligned with .

And Spring Boot Version correspondence

Spring Boot The emergence and popularity of the Internet has greatly alleviated the above situation , But use it Spring Cloud When it comes to Spring Boot The corresponding relationship between versions of is still needed Pay special attention to Of . So I've summed up this form for you :

Release Train Release time Spring Boot edition SC Commons edition
2020.0.x 2020-12 2.4.x 3.0.0
Hoxton 2019-07 2.2.x, 2.3.x ( from SR5 rise ) 2.2.x
Greenwich 2018-11 2.1.x 2.1.x
Finchley 2017-10 2.0.x 2.0.x
Edgware 2017-08 1.5.x 1.3.x
Dalston 2017-05 1.5.x 1.2.x
Brixton 2016-09 1.3.x 1.1.x
Angel 2016-05 1.2.x 1.0.x

explain : about Spring Cloud The internal components 、Spring Boot、Spirng Framework、Security And so on this huge system version contrast relations , The article has been sorted out , The next chapter sends out , Please remember to search

Special reminder :spring-cloud-starter-loadbalancer It's accompanied by Spring Cloud Commons 2.2.0 It's a commercial version (Hoxton edition ), Please pay attention to this version node , Because it replaces Ribbon.

Currently supported versions

Spring Cloud follow Pivotal OSS support policy Protocol pair Major version Provide 3 Years of support . Besides , stay Spring Cloud After the major or minor version of is released , If there is serious bug And security issues , It will be maintained for a while (6-12 Months to months ).

Particular attention : I mean Major version It's just 3 year , Major versions are rare

Now? 2020.0.0 Version released , It's time for elimination again . Now? Spring Cloud The official versions that will be supported are :

  • 2020.0 edition :( Support Spring Boot 2.4.x) It is Major version , As planned, we will support 2023 year 12 month
    • It's from Finchley Another major version after
  • Hoxton edition :( Support Spring Boot 2.2.x and 2.3.x) As Finchley Release a minor version of the series , Its routine maintenance will continue until 2021 year 6 End of month . from 2020-07 Start to enter the special maintenance period ( No new features , Just change to emergency bug),2021-12 At the end of the month, only major errors will be released / Security patch
  • Greenwich edition :( Support Spring Boot 2.1.x)2020-01 The maintenance stopped ,2020-12-31 It will also end its special maintenance period
  • Finchley edition :( Support Spring Boot 2.0.x) It's a Major version The beginning of ,2018 Released in
  • The older version : Um. , Forget it

Spring official Suggest : Try to use the latest version . But suggestions are suggestions , As only use Late mass We of Technology , I even feel safe in the second row . But the waves of history will eventually eliminate the front row , So it's always good to get ready early , Not to be pushed to the front row Swimming naked .

Spring Cloud 2020.0 As a Major version , Has brought about a lot of remarkable changes , There are some blocking updates ( Not downward compatible ) This is the biggest point of this article , Come on, serve .

Blocking upgrade ( Not downward compatible )

Almost last year (2019 year ) At this time of ,Spring Cloud In its Roadmap( It has been introduced in the previous article ) I announced that I was going to End Some libraries of / edition , The most important one is Spring Cloud Netflix The project enters maintenance mode , And then plan on 2020 It was completely removed in .

Spring Cloud Making such a decision is also “ Forced ”. We know Spring Cloud I've been putting Netflix OSS Suite as its official default one-stop solution , At that time Netflix OSS I wish I could be with Spring Cloud Equate . What's the matter ,Netflix The company in 2018 Announced its core components around the year Hystrix、Ribbon、Zuul、Archaius Wait for all to enter Maintenance state .

Although there are Zuul 2.x,Archaius 2.x, But none of them is downward compatible , No smooth upgrade , So it's almost impossible to use

from 2018 The modules that are in maintenance status since 1997 are ( Including its corresponding starter, Not listed here ):

  1. spring-cloud-netflix-archaius
  2. spring-cloud-netflix-hystrix-contract
  3. spring-cloud-netflix-hystrix-dashboard
  4. spring-cloud-netflix-hystrix-stream
  5. spring-cloud-netflix-hystrix
  6. spring-cloud-netflix-ribbon
  7. spring-cloud-netflix-turbine-stream
  8. spring-cloud-netflix-turbine
  9. spring-cloud-netflix-zuul

1、 goodbye ,Netflix

today ,Spring Cloud 2020.0 Official release , In this major version , Finally, according to the plan spring-cloud-netflix The knife's on . I drew a picture for you spring-cloud-netflix-dependencies Of xml A comparison of the main differences between the previous and later versions of the document , Be clear at a glance :

  • spring-cloud-netflix-dependencies It didn't disappear , It still exists , The version number is upgraded to 3.0.x edition
  • The old version of spring-cloud-netflix-dependencies Manages the Netflix All components , Include Hystrix、Ribbon、Zuul、Eureka etc. . And since 2020.0 Since version , It has and only manages Eureka( Include Server and Client)

interpretative statement :Feign Although it originally belonged to Netflix company , But from 9.x The version is handed over to OpenFeign Organize and manage , So it's no longer included Netflix Jurisdiction

In a nutshell :Spring Cloud 2020.0.0 edition Delete completely It fell off Netflix except Eureka External all Components . thus , We can be grateful with our hearts Netflix OSS Thank you , And can say goodbye to it .

explain :Netflix Of Eureka The project is still active , The design of this registration center is excellent , The overall performance is fair , The competitiveness in the market is still remarkable , therefore Spring Cloud I haven't given it up yet

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

Netflix Component alternatives

Spring Cloud Since you put Netflix OSS The kit was slashed , There must be an alternative . That's inevitable ,Spring Cloud The team recommended products for us to replace :

Netflix Recommend alternatives explain
Hystrix Resilience4j Hystrix I also recommend that you use it instead of yourself
Hystrix Dashboard / Turbine Micrometer + Monitoring System To put it bluntly , Monitoring this is left to more professional components
Ribbon Spring Cloud Loadbalancer I can't help it ,Spring After all, I will do it myself
Zuul 1 Spring Cloud Gateway I can't help it ,Spring After all, I will do it myself
Archaius 1 Spring Boot Externalized configuration + Spring Cloud To configure Than Netflix To achieve better 、 More powerful
Spring Cloud LoadBalancer What is it? ?

Among the above alternatives , You may be the stranger 、 What I'm most curious about is Spring Cloud Loadbalancer, It was just Spring Cloud The incubator A small project in , And once stranded . And then restart it , Development , The present makes its great mission , Officially used for Replace completely Ribbon, Become Spring Cloud Load Balancer The only way to achieve .

It is worth noting that :Spring Cloud LoadBalancer It was first introduced in Spring Cloud Commons 2.2.0 when , That is to say Hoxton The introduction of , It's just that it's just a spare tire / alternative , The default is still Ribbon Cantilever beam . The next screenshot is Hoxton Version :

Pictured , Load balancing abstraction LoadBalancerClient The interface has two implementations , And by the Spring Cloud 2020.0 After version ,BlockingLoadBalancerClient It's the only way to achieve .

About spring-cloud-loadbalancer The use of load balancers , There's an extremely recommended course for the government :https://spring.io/guides/gs/spring-cloud-loadbalancer. If you are interested, you can play by yourself , If you're not interested , Then pay attention to my later article analysis , I'll introduce it specially

Spring Cloud Alibaba Can it be used as an alternative ?

Um. , It's fine too .

But it's not Spring Cloud Official recommended default scheme . We look forward to the joint efforts of the Chinese people , We can deliver as soon as possible Spring Cloud Alibaba Up , Let the crooked nuts use the framework of China , carry issue It has to be in Chinese O(∩_∩)O ha-ha ~.

Show import Netflix Is the bag still working work?

Want to upgrade to the latest version of Spring Cloud, I want to keep downward compatibility Netflix Technology . although spring-cloud-netflix-dependencies It no longer contains netflix Core components , Can I guide the package manually and specify the version number ? Is it normal work Well ?

answer : I'll give you an answer by patting my head , no way . Since I haven't argued , But it's freaky to use it like this , The plan should be shot in the bud , There should be no .

in addition , This also tells us that : Use Spring Cloud Try to face it as much as possible abstract Programming , Even though Spirng Cloud Change the underlying components ( If you change the fuse 、 Load Balancer ) wait , Theoretically, it has no or little impact on our business , It's all thanks to its Spring Cloud Commons abstract , That's the cream .

2、Bootstrap The context is no longer started by default

Students who know the principles know ,Spring Cloud The container depends on Bootstrap Context Guide the context to start , The corresponding class is BootstrapApplicationListener.

This is in 2020.0 The version has changed , The new version of the Spring Cloud No longer dependent on this context to start . So by default , Will no longer start Bootstrap Context . The code level changes are happening here :

BootstrapApplicationListener:

	@Override
	public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
		ConfigurableEnvironment environment = event.getEnvironment();
		//  Add this judgment at the beginning of the method 
		if (!bootstrapEnabled(environment) && !useLegacyProcessing(environment)) {
			return;
		}
		...
	}

PropertyUtils:

	// BOOTSTRAP_ENABLED_PROPERTY = spring.cloud.bootstrap.enabled
	public static boolean bootstrapEnabled(Environment environment) {
		return environment.getProperty(BOOTSTRAP_ENABLED_PROPERTY, Boolean.class, false) || MARKER_CLASS_EXISTS;
	}
	// USE_LEGACY_PROCESSING_PROPERTY = spring.config.use-legacy-processing
	public static boolean useLegacyProcessing(Environment environment) {
		return environment.getProperty(USE_LEGACY_PROCESSING_PROPERTY, Boolean.class, false);
	}

Opening mode

If you need to turn on Bootstrap Context , There are two ways to do it :

  1. Set the value spring.cloud.bootstrap.enabled=true perhaps spring.config.use-legacy-processing=true that will do . Be careful : These attribute values must be ensured that they can be put into the environment in order to take effect . For example, the reliable way is : System attribute 、 environment variable 、 Command line, etc
  2. The introduction of a Jar:org.springframework.cloud:spring-cloud-starter-bootstrap, And then there's nothing to do
    1. explain : This jar There is only one Marker class , The effect you know , I won't explain too much here

explain : Open manually Bootstrap Context , Prove that you fallback Load in the old way SC, Then please do everything in the old way

3、 New configuration

Thanks to the Spring Boot 2.4.x Support a new way to write configuration files , From then on, you can use spring.config.import Both import the configuration of the other build . Such as :

  • spring.config.import=configserver:xxx
  • spring.config.import=zookeeper:
  • ...

It's more modular , More in line with the requirements of cloud native environment .

4、 Other

  • To disable Spring Cloud Config Client The health indicator on the end uses health.config.enabled=false, Now changed to management.health.config.enabled=false. Keep up with Spring Boot Control endpoint style consistency
  • With invalid characters ( Dashes ) The endpoint of id It has been changed to meet the standard , Since then, there have been no annoying warnings at the start-up , Save the Puritans .
    • bus-env -> busenv
    • bus-refresh -> busrefresh
    • service-registry -> serviceregistry
// old
@Endpoint(id = "service-registry")
public class ServiceRegistryEndpoint { ... }

// new
@Endpoint(id = "serviceregistry")
public class ServiceRegistryEndpoint { ... }

Regular upgrade

There's not so much focus on regular upgrades , Mainly for its components such as Spring Cloud Commons、Spring Cloud Kubernetes、Spring Cloud Openfeign... Wait for some regular upgrades , lackluster .

One thing that deserves attention :Spirng Cloud be-all Module Version numbers have been upgraded to 3.0.0( Upgrade of large version number ), except Spring Cloud Circuitbreaker/Spring Cloud Kubernetes(2.0.0) and Spring Cloud Task(2.3.0) outside .

The problems that still exist

although 2020.0 already RELEASE 了 , But there are still unsolved problems , Take a few examples of this version Existing The problem of :

  • If you use spring.config.import=configserver: To configure the configuration center , This version is missing support retry Parameters
    • Solution : If you want to use it , You have to fallback To the traditional way ( Written in bootstrap.yaml in )
  • spring-cloud-config-dependencies There is a non release Version of jar( Take a look at the screenshot )
    • Solution : Manually specify the jar Version number of

explain :M1 It's a milestone version , It also belongs to the early stage of getting up , Possible bug, It is recommended that you manually specify the version number to replace this jar

It seems that even if it is better than Spring The team , There will be all kinds of mistakes . If you think about it , I dare to go back to write bug Go .

summary

Spring Cloud 2020.0.0 yes Spring Cloud Of Major version , It's a very important existence , upgrade 、 The change is also huge . It is especially reflected in Netflix Removal of all modules 、Spring Cloud The start-up mode has changed and so on . With Spring Boot 2.4.x as well as Spirng Cloud 2020.0 Release , And discard Netflix OSS After the kit , Will enter a new Deep programming Experience , Full of surprise , I'm looking forward to .

explain : Because this version completely discards Netflix A set of things , To keep up with the times , I'll use it for a while and then , Write the latest version of the series as soon as possible , Help you step on the pit less

It is mentioned at the end of the article that 2020.0 Although the version has been released , But there are still some problems . But then again , Those are small problems , It may be fixed in the next small version . But the embarrassment is , distance 2020 The end of the year is less than 10 days , If you enter 2021 year , Name the new rules according to the version number , The version issued at that time will no longer be called 2020.x.x And can only be 2021.x.x, Obviously, this is a big version number iteration , You need to be careful .

You feel Spring Cloud Team in 2020 Will it be published in 2010 ? Welcome to leave your comments in the comments area .


【Spring Type conversion 】 series :

【Jackson】 series :

【 data verification Bean Validation】 series :

【 New characteristics 】 series :

【 Programmed life 】 series :

And things like 【Spring Configuration class 】【Spring-static】【Spring Data binding 】【Spring Cloud Netflix】【Feign】【Ribbon】【Hystrix】... More original Columns , Focus on BAT The Utopia of reply special column You can get all of them in two words , You can also add me fsx1056342982, Make a friend .

There are some It's over , There are some In the serial . I am a A Brother (YourBatman), I'll see you next time

版权声明
本文为[YourBatman]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224082206209z.html

Scroll to Top