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

Spring Boot 3.x 集成 Eureka Server/Client的詳細(xì)過(guò)程

 更新時(shí)間:2024年09月30日 10:38:50   作者:Kenny.志  
隨著SpringBoot 3.x版本的開(kāi)發(fā)嘗試,本文記錄了在集成Eureka Server/Client時(shí)所遇到的問(wèn)題和解決方案,文中詳細(xì)介紹了搭建服務(wù)、配置文件和測(cè)試步驟,感興趣的朋友跟隨小編一起看看吧

一、前言

基于 Spring Boot 3.x 版本開(kāi)發(fā),因?yàn)?Spring Boot 3.x 暫時(shí)沒(méi)有正式發(fā)布,所以很少有 Spring Boot 3.x 開(kāi)發(fā)的項(xiàng)目,自己也很想了踩踩坑,看看 Spring Boot 3.x 與 2.x 有什么區(qū)別。自己與記錄一下在 Spring Boot 3.x 過(guò)程中遇到一下問(wèn)題

二、搭建服務(wù)

chain 服務(wù)

pom.xml 文件,我這里使用的是 Spring Boot 版本 3.3.4,Spring Cloud 版本是 2023.0.3

    <!-- 依賴版本管理,用于管理子模塊的依賴版本 -->
    <properties>
        <!-- 項(xiàng)目編碼 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- java編譯版本 -->
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <!-- java版本 -->
        <java.version>17</java.version>
        <!-- chain 版本 -->
        <chain.version>1.0.0</chain.version>
        <!--SpringCloud版本-->
        <spring-cloud.version>2023.0.3</spring-cloud.version>
        <!-- spring-boot版本 -->
        <spring.boot.version>3.3.4</spring.boot.version>
        <!-- spring framework版本 -->
        <spring.framework.version>6.1.13</spring.framework.version>
    </properties>
<!-- 依賴聲明 -->
    <dependencyManagement>
        <dependencies>
            <!--依賴管理,用于管理spring-cloud的依賴 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- spring framework版本 -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>${spring.framework.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- spring-boot版本2.5.15更換為3.2.4 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.3.4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

子服務(wù) eureka-server

pom.xml 文件

    <dependencies>
        <!-- eureka server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
        <!-- spring boot starter test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

EurekaServerAPP

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApp {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApp.class);
    }
}

application.yml

server:
  # 監(jiān)聽(tīng)端口
  port: 10001
spring:
  application:
    # 服務(wù)名稱
    name: eureka-server
eureka:
  instance:
    # eureka 服務(wù)實(shí)例的主機(jī)名稱
    hostname: ${spring.application.name}
  client:
    # 表示是否將自己注冊(cè)進(jìn)EurekaServer默認(rèn)為true
    register-with-eureka: false
    # 表示是否從EurekaServer抓取已有的注冊(cè)信息,默認(rèn)為true
    fetch-registry: false
    # EurekaServer服務(wù)提供地址
    service-url:
      # 單機(jī)版
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

上面三個(gè)文件配置完畢之后,可以啟動(dòng)一下 EurekaServerApp 看一下,是否有配置問(wèn)題,要是在控制臺(tái)出現(xiàn)以下內(nèi)容,就代表 eureka-server 配置完畢了
服務(wù)

到這里,可以打開(kāi)瀏覽器訪問(wèn) eureka-server 管理頁(yè)面看看,http://localhost:10001 

到此為止,eureka 的服務(wù)端就已經(jīng)搭建完畢

子服務(wù) system-server

pom.xml

<dependencies>
        <!-- eureka client -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <!-- spring boot web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- spring boot starter test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- spring boot devtools -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>

SystemServerApp

@SpringBootApplication
@EnableDiscoveryClient
public class SystemServerApp {
    public static void main(String[] args) {
        SpringApplication.run(SystemServerApp.class);
    }
}

application.yml

server:
  # 監(jiān)聽(tīng)端口
  port: 10010
  servlet:
    # 應(yīng)用的訪問(wèn)路徑
    context-path: /
spring:
  application:
    # 服務(wù)名稱
    name: system-service
eureka:
  instance:
    # eureka 服務(wù)實(shí)例的主機(jī)名稱
    hostname: ${spring.application.name}
    # 服務(wù)實(shí)例的注冊(cè)ID
    #lease-instance-id: ${spring.application.name}:${server.port}
    # 服務(wù)實(shí)例的注冊(cè)時(shí)間間隔,單位為秒
    #lease-renewal-interval-in-seconds: 5
  # 是否開(kāi)啟安全認(rèn)證
  #security:
    #basic:
      #enabled: false
  client:
    # 表示是否將自己注冊(cè)進(jìn)EurekaServer默認(rèn)為true
    register-with-eureka: true
    # 表示是否從EurekaServer抓取已有的注冊(cè)信息,默認(rèn)為true
    # 單節(jié)點(diǎn)無(wú)所謂,集群必須設(shè)置為true才能配合ribbon使用負(fù)載均衡
    fetch-registry: true
    # EurekaServer服務(wù)提供地址
    service-url:
      # 單機(jī)版
      defaultZone: http://localhost:10001/eureka/

同樣啟動(dòng)一下 system-server 服務(wù)測(cè)試

也可以看一下在 eureka-server 服務(wù)中是否有 system-server 注冊(cè)信息

也可以去到 eureka-server 管理頁(yè)面,看看 system-server 是否注冊(cè)成功

搭建 eureka server/client 相對(duì)比較簡(jiǎn)單,在這個(gè)過(guò)程中主要是要找對(duì) Spring Boot 與 Spring Cloud 的版本即可,eureka 的配置項(xiàng),還是老舊的那一套,沒(méi)有太大的變化

到此這篇關(guān)于Spring Boot 3.x 集成 Eureka Server/Client的文章就介紹到這了,更多相關(guān)Spring Boot 集成 Eureka Server/Client內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • linux部署出現(xiàn)java文件操作報(bào)錯(cuò):java.io.FileNotFoundException解決辦法

    linux部署出現(xiàn)java文件操作報(bào)錯(cuò):java.io.FileNotFoundException解決辦法

    這篇文章主要g介紹了linux部署出現(xiàn)java文件操作報(bào)錯(cuò):java.io.FileNotFoundException解決的相關(guān)資料,這個(gè)錯(cuò)誤通常表示你的Spring Boot應(yīng)用程序無(wú)法找到指定的文本文件,需要的朋友可以參考下
    2023-12-12
  • Mybatis中的延遲加載案例解析

    Mybatis中的延遲加載案例解析

    這篇文章主要介紹了Mybatis中的延遲加載,場(chǎng)景結(jié)合案例分析非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-12-12
  • Spring中獲取HttpServletRequest的三種方式小結(jié)

    Spring中獲取HttpServletRequest的三種方式小結(jié)

    spring框架web環(huán)境中,獲取HttpServletRequest是常見(jiàn)的操作,本文將為大家詳細(xì)介紹一下Spring中獲取HttpServletRequest的三種方式,有需要的小伙伴可以了解下
    2026-04-04
  • idea如何開(kāi)啟菜單欄

    idea如何開(kāi)啟菜單欄

    文章介紹了如何通過(guò)修改IntelliJ IDEA的樣式文件`ui.lnf.xml`來(lái)重新顯示被關(guān)閉的菜單欄,并分享了解決問(wèn)題的步驟
    2025-01-01
  • SpringCloud微服務(wù)踩坑記錄分享

    SpringCloud微服務(wù)踩坑記錄分享

    本文記錄了作者在使用SpringCloud微服務(wù)時(shí)遇到的問(wèn)題,首先,作者嘗試修改配置文件中的service-name和instance-id,但仍然無(wú)法解決問(wèn)題,后來(lái),作者嘗試更換SpringCloud版本為2.2.5,并搭配Hoxton.SR3版本,問(wèn)題得以解決
    2024-11-11
  • 關(guān)于Springboot如何獲取IOC容器

    關(guān)于Springboot如何獲取IOC容器

    大家好,我是孤焰。最近我在制作日志審計(jì)功能時(shí)發(fā)現(xiàn)不知道怎樣獲取到Springboot項(xiàng)目中的IOC容器,經(jīng)過(guò)摸索,最終解決了這個(gè)問(wèn)題,現(xiàn)在把解決方式和大家分享一下
    2021-08-08
  • myBatis實(shí)現(xiàn)三級(jí)嵌套復(fù)雜對(duì)象的賦值問(wèn)題

    myBatis實(shí)現(xiàn)三級(jí)嵌套復(fù)雜對(duì)象的賦值問(wèn)題

    這篇文章主要介紹了myBatis實(shí)現(xiàn)三級(jí)嵌套復(fù)雜對(duì)象的賦值問(wèn)題,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11
  • JavaMe開(kāi)發(fā)繪制文本框TextEdit

    JavaMe開(kāi)發(fā)繪制文本框TextEdit

    在JavaMe連載(3)-也說(shuō)MVC設(shè)計(jì)模式 一文中提到了一個(gè)TextEdit類,但沒(méi)有給出具體實(shí)現(xiàn),TextEdit是采用GameCanvas繪制的文本編輯器。本文結(jié)合實(shí)例給出實(shí)現(xiàn)的方法。
    2015-09-09
  • 使用Java實(shí)現(xiàn)創(chuàng)建Excel表單控件

    使用Java實(shí)現(xiàn)創(chuàng)建Excel表單控件

    在數(shù)據(jù)填報(bào)時(shí),創(chuàng)建Excel表單控件是一項(xiàng)常見(jiàn)的任務(wù),它可以極大地簡(jiǎn)化數(shù)據(jù)收集和處理的過(guò)程,本文主要介紹了如何使用Java實(shí)現(xiàn)創(chuàng)建Excel表單控件,感興趣的可以了解下
    2024-03-03
  • 詳解Java七大阻塞隊(duì)列之SynchronousQueue

    詳解Java七大阻塞隊(duì)列之SynchronousQueue

    SynchronousQueue不需要存儲(chǔ)線程間交換的數(shù)據(jù),它的作用像是一個(gè)匹配器,使生產(chǎn)者和消費(fèi)者一一匹配。本文詳細(xì)講解了Java七大阻塞隊(duì)列之一SynchronousQueue,需要了解的小伙伴可以參考一下這篇文章
    2021-09-09

最新評(píng)論

迁西县| 潞西市| 崇明县| 洛浦县| 松阳县| 田阳县| 综艺| 绿春县| 行唐县| 鄂伦春自治旗| 法库县| 高邮市| 大名县| 德兴市| 麟游县| 玉林市| 晋江市| 鄱阳县| 富裕县| 临高县| 阿图什市| 新建县| 黔西县| 漳州市| 防城港市| 彰武县| 融水| 甘南县| 英德市| 蒙自县| 海阳市| 资溪县| 平果县| 万山特区| 定兴县| 沐川县| 定边县| 延长县| 财经| 拉孜县| 仪征市|