最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

分享Spring Boot 3.x微服務(wù)升級歷程

 更新時間:2022年12月16日 12:03:58   投稿:mrr  
Spring Boot 3.0.0 GA版已經(jīng)發(fā)布,好多人也開始嘗試升級,有人測試升級后,啟動速度確實快了不少,這篇文章主要介紹了Spring Boot 3.x微服務(wù)升級經(jīng)歷,需要的朋友可以參考下

前言

Spring Boot 3.0.0 GA版已經(jīng)發(fā)布,好多人也開始嘗試升級,有人測試升級后,啟動速度確實快了不少,如下為網(wǎng)絡(luò)截圖,于是我也按捺不住的想嘗試下。

在這里插入圖片描述

歷程

首先就是要把Spring Boot、Spring Cloud 相關(guān)的依賴升一下
Spring Boot:3.0.0
Spring Cloud:2022.0.0-RC2

統(tǒng)一依賴版本管理:

<dependencyManagement>
<dependencies>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-dependencies</artifactId>
		<version>2022.0.0-RC2</version>
		<type>pom</type>
		<scope>import</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.0.0</version>
		<type>pom</type>
		<scope>import</scope>
	</dependency>
</dependencies>
</dependencyManagement>

現(xiàn)在還不能下載Spring 相關(guān)依賴包,需要加入Spring 倉庫。
在你的maven倉庫中加入如下配置,我是加在了pom.xml

<repository>
	<id>netflix-candidates</id>
	<name>Netflix Candidates</name>
	<url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates</url>
	<snapshots>
		<enabled>false</enabled>
	</snapshots>
</repository>
<repository>
	<id>spring-milestones</id>
	<name>Spring Milestones</name>
	<url>https://repo.spring.io/milestone</url>
	<snapshots>
		<enabled>false</enabled>
	</snapshots>
</repository>

另外Spring Boot 3.X 開始使用了Java 17,將java版本調(diào)整到>17,為了不必要的麻煩,就選17
IDEA選擇17,并在pom.xml文件中指定版本:

<java.version>17</java.version>

到這里我們的common 包是能正常編譯了。

接下來是服務(wù)的配置
同樣調(diào)整Spring Boot、Spring Cloud、Java的版本,同common的配置。
碰到如下的幾個問題:

找不到hystrix的依賴問題
升級后找不到hystrix的版本,官網(wǎng)也找不到,這里我顯式指定了版本

<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
	<version>2.2.9.RELEASE</version>
</dependency>

rabbitmq問題
相關(guān)的配置丟失,比如如下圖,這邊進(jìn)行適當(dāng)調(diào)整或者直接注釋解決。

在這里插入圖片描述

在這里插入圖片描述

TypeVariableImpl丟失問題
原來服務(wù)中引入了sun.reflect.generics.reflectiveObjects.TypeVariableImpl,現(xiàn)在17中已經(jīng)被隱藏?zé)o法直接使用,這邊為了能夠先啟動,暫時注釋,后面再想辦法。

Log 異常問題
由于之前我們項目中歷史原因,既有用log4j,也有用logback,升級后已經(jīng)不行,提示沖突,報錯如下

Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from file:/Users/chenjujun/.m2/repository/org/slf4j/slf4j-api/1.7.0/slf4j-api-1.7.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.helpers.NOPLoggerFactory
    at org.springframework.util.Assert.instanceCheckFailed(Assert.java:713)
    at org.springframework.util.Assert.isInstanceOf(Assert.java:632)

意思是,要么移除Logback,要么解決slf4j-api的沖突依賴,這里兩種方式都嘗試了,slf4j-api依賴的地方太多,后面移除了Logback。

要排除依賴一個好辦法:使用Maven Helper插件

在這里插入圖片描述

logback依賴:

<dependency>
	<groupId>ch.qos.logback</groupId>
	<artifactId>logback-classic</artifactId>
	<version>1.2.8</version>
</dependency>

Apollo問題
使用Apollo會提示該錯誤,需要在啟動中加入--add-opens java.base/java.lang=ALL-UNNAMED

Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory!
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:40)
    at com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer.<init>(ApolloApplicationContextInitializer.java:66)
    ... 16 more
Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Apollo Spring Injector!
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInjector(SpringInjector.java:24)
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:37)
    ... 17 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @16612a51
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:52)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:42)

通過上述配置調(diào)整后,能編譯成功,但是無法啟動,控制沒有任何日志,初步懷疑還是log依賴問題,由于時間關(guān)系,沒有再繼續(xù),問題留到以后再弄,后面有新進(jìn)展,會持續(xù)更新該文。

到此這篇關(guān)于Spring Boot 3.x微服務(wù)升級經(jīng)歷的文章就介紹到這了,更多相關(guān)Spring Boot 3.x微服務(wù)升級內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java Agent 動態(tài)修改字節(jié)碼詳情

    Java Agent 動態(tài)修改字節(jié)碼詳情

    這篇文章主要介紹了Java Agent動態(tài)修改字節(jié)碼的相關(guān)資料,需要的朋友可以參考下面文章具體的內(nèi)容
    2021-09-09
  • RestTemplate的DELETE及PUT等請求方法使用精講

    RestTemplate的DELETE及PUT等請求方法使用精講

    這篇文章主要為大家介紹了RestTemplate的DELETE及PUT等請求方法的使用精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2022-03-03
  • Java實現(xiàn)文件上傳到服務(wù)器本地并通過url訪問的方法步驟

    Java實現(xiàn)文件上傳到服務(wù)器本地并通過url訪問的方法步驟

    最近項目中使用到了文件上傳到服務(wù)器的功能,下面這篇文章主要給大家介紹了關(guān)于Java實現(xiàn)文件上傳到服務(wù)器本地并通過url訪問的方法步驟,文中通過圖文以及實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • Spring Security的持久化用戶和授權(quán)實現(xiàn)方式

    Spring Security的持久化用戶和授權(quán)實現(xiàn)方式

    文章介紹了如何使用JdbcUserDetailsManager實現(xiàn)數(shù)據(jù)庫讀取用戶,并展示了如何配置SpringSecurity進(jìn)行授權(quán)管理,通過創(chuàng)建數(shù)據(jù)庫表、配置數(shù)據(jù)庫連接和修改SecurityConfig,實現(xiàn)了用戶權(quán)限的控制
    2025-02-02
  • StreamAPI多次消費(fèi)一個stream代碼實例

    StreamAPI多次消費(fèi)一個stream代碼實例

    這篇文章主要介紹了StreamAPI多次消費(fèi)一個stream代碼實例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-04-04
  • java實現(xiàn)String字符串處理各種類型轉(zhuǎn)換

    java實現(xiàn)String字符串處理各種類型轉(zhuǎn)換

    在日常的程序開發(fā)中,經(jīng)常會涉及到不同類型之間的轉(zhuǎn)換,本文主要介紹了String字符串處理各種類型轉(zhuǎn)換,具有一定的參考價值,感興趣的可以了解一下
    2023-10-10
  • SpringBoot實現(xiàn)對Http接口進(jìn)行監(jiān)控的代碼

    SpringBoot實現(xiàn)對Http接口進(jìn)行監(jiān)控的代碼

    Spring Boot Actuator是Spring Boot提供的一個模塊,用于監(jiān)控和管理Spring Boot應(yīng)用程序的運(yùn)行時信息,本文將介紹一下Spring Boot Actuator以及代碼示例,以及如何進(jìn)行接口請求監(jiān)控,需要的朋友可以參考下
    2024-07-07
  • 詳解eclipse項目中的.classpath文件原理

    詳解eclipse項目中的.classpath文件原理

    這篇文章介紹了eclipse項目中的.classpath文件的原理,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-12-12
  • 關(guān)于kafka消費(fèi)不到遠(yuǎn)程bootstrap-server?數(shù)據(jù)的問題

    關(guān)于kafka消費(fèi)不到遠(yuǎn)程bootstrap-server?數(shù)據(jù)的問題

    很多朋友遇到kafka消費(fèi)不到遠(yuǎn)程bootstrap-server?數(shù)據(jù)的問題,怎么解決這個問題,很多朋友不知所措,下面小編給大家?guī)砹岁P(guān)于kafka消費(fèi)不到遠(yuǎn)程bootstrap-server?數(shù)據(jù)的問題及解決方法,感興趣的朋友跟隨小編一起看看吧
    2021-11-11
  • 一文掌握Spring?中?@Component?和?@Bean?區(qū)別(最新推薦)

    一文掌握Spring?中?@Component?和?@Bean?區(qū)別(最新推薦)

    ?@Component?用于標(biāo)識一個普通的類,@Bean用于配置類里面,在方法上面聲明和配置?Bean?對象,這篇文章主要介紹了Spring?中?@Component?和?@Bean?區(qū)別(最新推薦),需要的朋友可以參考下
    2024-04-04

最新評論

宜宾县| 阳江市| 卢龙县| 杭锦后旗| 阳信县| 新龙县| 玛多县| 维西| 北安市| 轮台县| 岳西县| 抚松县| 通榆县| 乌拉特中旗| 宽城| 木里| 修文县| 砚山县| 聂拉木县| 区。| 拉孜县| 茂名市| 沈丘县| 自贡市| 鄱阳县| 巴林左旗| 南皮县| 会宁县| 大理市| 开封市| 青冈县| 博湖县| 嵊州市| 尉犁县| 常熟市| 淳化县| 东山县| 马关县| 光泽县| 临沭县| 滦平县|