SpringCloud 學習總結(思維導圖)
詳細內容
相關配置資訊
工程目錄:
關於application.yml中的配置:
服務提供者:provider
server:
port: 8081
#資料庫連線資訊
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/boot?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
username: root
password: 123456
application:
name: service-provider #將來會作為微服務的名稱
#配置mybatis資訊,pojo別名掃描包
mybatis:
type-aliases-package: com.ly.domain
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
register-with-eureka: true #預設值為true,服務提供方啟動時,會檢測該引數是否為true,true-註冊給eureka
instance:
lease-renewal-interval-in-seconds: 5 #心跳時間
lease-expiration-duration-in-seconds: 15 #過期時間
服務呼叫者:consumer
server:
port: 8088
spring:
application:
name: service-consumer #將來會作為微服務的名稱
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
fetch-registry: true #是否拉取服務,預設為true
registry-fetch-interval-seconds: 5 #拉取服務的間隔時間
service-provider:
ribbon:
NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 6000 #設定hystrix的超時時間為6000ms
feign:
hystrix:
enabled: true #開啟Feign的熔斷功能
Eureka服務註冊中心:
server:
port: 10086
spring:
application:
name: ly-eureka #將來會作為微服務名稱注入到eureka容器
eureka:
client:
service-url:
defaultZone: http://localhost:${server.port}/eureka
#server:
#eviction-interval-timer-in-ms: 5000 #失效剔除時間,單位毫秒
#enable-self-preservation: false #關閉自我保護狀態
Zuul閘道器:
server:
port: 10010
spring:
application:
name: ly-zuul
#zuul: #路由配置方式1
#routes:
#service-provider:
#path: /service-provider/**
#url: http://localhost:8081
#zuul: #路由配置方式2
#routes:
#service-provider:
#path: /service-provider/**
#serviceId: service-provider
zuul: #路由配置方式3,推薦
routes:
service-provider: /provider/**
service-consumer: /consumer/**
prefix: /api
eureka:
client:
service-url:
defaultZone: http://localhost:10086/eureka
服務提供者:springboot-service-provider的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.11.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ly</groupId>
<artifactId>springboot_service_provider</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot_service_provider</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
服務呼叫者:springboot-service-consumer的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.11.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ly</groupId>
<artifactId>springboot-service-consumer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-service-consumer</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
服務註冊中心springboot-eureka的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.11.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ly</groupId>
<artifactId>springboot-eureka</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-eureka</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
閘道器ly-zuul的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.11.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ly</groupId>
<artifactId>ly-zuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ly-zuul</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
相關文章
- 思維導圖概覽SpringCloudSpringGCCloud
- Greenplum 學習實踐-總體思維導圖
- python學習_思維導圖Python
- javaSE之物件導向思維導圖總結Java物件
- 圖解HTTP知識總結(思維導圖)圖解HTTP
- 第七週學習思維導圖
- 思維導圖學 MavenMaven
- 學習Java的9張思維導圖Java
- 《統計學習方法》思維導圖-中
- 《統計學習方法》思維導圖-上
- SpringCloud 學習總結SpringGCCloud
- Java知識彙總——思維導圖Java
- 乾貨!學習 Python 的 14 張思維導圖Python
- 微信小程式--學習筆記(思維導圖)微信小程式筆記
- java核心技術卷1學習思維導圖Java
- 零基礎入門運維必備 | 一文總結學習 Python 的 14 張思維導圖運維Python
- typora思維導圖
- 前端思維導圖前端
- 大話資料結構-思維導圖資料結構
- Xmind使用教程:給思維導圖加水印 「Xmind思維導圖2023」
- 英語?思維導圖?
- 常用思維導圖工具
- 觀潮思維導圖
- 前端思維導圖 8前端
- 思維導圖Xmind 2022
- 思維導圖軟體
- 運維工程師思維導圖運維工程師
- 思維導圖教程是什麼?該怎樣繪製思維導圖?
- 3A Cloud 思維導圖 for Mac(思維導圖軟體)中文版CloudMac
- 思維導圖軟體——MindMaster常用快捷鍵彙總AST
- 使用Kimi+Markmap總結檔案內容生成思維導圖原創
- 高等數學-多元函式微分學思維導圖函式
- iMindMap教你用思維導圖記憶法制作古詩思維導圖
- 思維導圖軟體哪個好,英語思維導圖怎麼畫
- vue-router思維導圖Vue
- Python(模組)思維導圖Python
- OpenTelemetry Logging 思維導圖,收藏
- XMind 2022 XMind思維導圖