“第一个 Eureka Server”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) (建立内容为“https://www.bilibili.com/video/BV1eU4y187zE/?p=9 搭建 Eureka Server 时就相当于在安装 Eureka 软件(在 Spring Cloud 学习的一种全新方式,替…”的新页面) |
Jihongchang(讨论 | 贡献) (→导入依赖) |
||
第7行: | 第7行: | ||
添加 Spring Boot 依赖和 Spring Cloud 集成的 Eureka Server 依赖。 | 添加 Spring Boot 依赖和 Spring Cloud 集成的 Eureka Server 依赖。 | ||
− | 所有依赖的版本都是最新版。 | + | 所有依赖的版本都是最新版。<syntaxhighlight lang="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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
+ | <modelVersion>4.0.0</modelVersion> | ||
+ | |||
+ | <groupId>io.github.jihch</groupId> | ||
+ | <artifactId>eureka-server</artifactId> | ||
+ | <version>1.0-SNAPSHOT</version> | ||
+ | |||
+ | <parent> | ||
+ | <groupId>org.springframework.boot</groupId> | ||
+ | <artifactId>spring-boot-starter-parent</artifactId> | ||
+ | <version>2.3.3.RELEASE</version> | ||
+ | </parent> | ||
+ | |||
+ | <properties> | ||
+ | <maven.compiler.source>8</maven.compiler.source> | ||
+ | <maven.compiler.target>8</maven.compiler.target> | ||
+ | </properties> | ||
+ | |||
+ | |||
+ | <dependencyManagement> | ||
+ | <dependencies> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework.cloud</groupId> | ||
+ | <artifactId>spring-cloud-dependencies</artifactId> | ||
+ | <version>Hoxton.SR8</version> | ||
+ | <type>pom</type> | ||
+ | <scope>import</scope> | ||
+ | </dependency> | ||
+ | </dependencies> | ||
+ | </dependencyManagement> | ||
+ | |||
+ | |||
+ | <dependencies> | ||
+ | <!-- 由于已经依赖的 web 所以不需要单独再导入一次 web --> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework.cloud</groupId> | ||
+ | <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> | ||
+ | </dependency> | ||
+ | |||
+ | </dependencies> | ||
+ | |||
+ | </project> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | === 编写配置文件 === | ||
+ | 在 application.yml 中添加以下内容,不添加会报错。 | ||
+ | |||
+ | 此处要求 tomcat 端口和 Eureka Server 的端口是相同的。 | ||
+ | |||
+ | Eureka Server 默认端口是 8761,所以此处配置为 8761。 | ||
+ | |||
+ | 如果此处希望配置为 8082 等非 8761 端口,需要打开注释。 |
2023年3月7日 (二) 04:06的版本
https://www.bilibili.com/video/BV1eU4y187zE/?p=9
搭建 Eureka Server 时就相当于在安装 Eureka 软件(在 Spring Cloud 学习的一种全新方式,替换了之前需要安装对应软件的问题)。
导入依赖
添加 Spring Boot 依赖和 Spring Cloud 集成的 Eureka Server 依赖。
所有依赖的版本都是最新版。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.jihch</groupId>
<artifactId>eureka-server</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
</parent>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- 由于已经依赖的 web 所以不需要单独再导入一次 web -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
</project>
编写配置文件
在 application.yml 中添加以下内容,不添加会报错。
此处要求 tomcat 端口和 Eureka Server 的端口是相同的。
Eureka Server 默认端口是 8761,所以此处配置为 8761。
如果此处希望配置为 8082 等非 8761 端口,需要打开注释。