springcloud Eureka Finchley.RELEASE 版本
创建一个父项目cloud-demo
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId>
<artifactId>cloud-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>cloud-demo</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <modules>
<module>eureka-server</module>
<module>eureka-client</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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>
可以直接把src下的都删除,用不到。然后创建2个model,分别为eureka-server,eureka-client,
eureka-server 的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>eureka-server</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>com.example</groupId>
<artifactId>cloud-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
eureka-server 启动类 EurekaServerApplication
package com.example.eurekaserver; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication
@EnableEurekaServer // 启动一个服务注册中心提供给其他应用进行对话
public class EurekaServerApplication { public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
application.yml
server:
port: 8761 eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ spring:
application:
name: eurka-server
一个简单的server就完成了。
eureka-client 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId>
<artifactId>eureka-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>eureka-client</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>com.example</groupId>
<artifactId>cloud-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <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>
</dependency> <!-- actuator监控信息完善 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
client 启动类 EurekaClientApplication
package com.example.eurekaclient; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; @SpringBootApplication
@EnableEurekaClient
@RestController
public class EurekaClientApplication { public static void main(String[] args) {
SpringApplication.run(EurekaClientApplication.class, args);
} @Value("${server.port}")
String port; @RequestMapping("/hi")
public String home(@RequestParam(value = "name", defaultValue = "forezp") String name) {
return "hi " + name + " ,i am from port:" + port;
}
}
application.yml
server:
port: 8762 spring:
application:
name: service-hi eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
instance-id: service-hi
prefer-ip-address: true
info:
app.name: eureka-client
company.name: www.zhaowb.com
build.artifactId: eureka-client
build.version: 0.0.1-SNAPSHOT
然后启动结果:
instance:
instance-id: service-hi
prefer-ip-address: true
当将鼠标放在service-hi 在左下角会显示IP信息
info:
app.name: eureka-client
company.name: www.zhaowb.com
build.artifactId: eureka-client
build.version: 0.0.1-SNAPSHOT
编辑client 的信息,当点击service-hi
这是添加上之后的结果
<!-- actuator监控信息完善 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
这个jar包之后的结果,如果不加的话,会出现这个错误
为了不让出错,和显示一些信息,就添加上了jar 和一些配置信息。
源码地址 https://github.com/zhaowenbo1234/cloud-demo
springcloud Eureka Finchley.RELEASE 版本的更多相关文章
- SpringCloud 教程 | 第一篇: 服务的注册与发现Eureka(Finchley版本)
一.spring cloud简介 鉴于<史上最简单的Spring Cloud教程>很受读者欢迎,再次我特意升级了一下版本,目前支持的版本为Spring Boot版本2.0.3.RELEAS ...
- 史上最简单的 SpringCloud 教程 | 第一篇: 服务的注册与发现Eureka(Finchley版本)
转载请标明出处: 原文首发于:https://www.fangzhipeng.com/springcloud/2018/08/30/sc-f1-eureka/ 本文出自方志朋的博客 一.spring ...
- 第一篇:服务的注册与发现Eureka(Finchley版本)
一.创建服务注册中心(Eureka) 1. 首先创建一个maven主工程 创建一个主Maven工程,在其pom文件引入依赖,spring Boot版本为2.0.3.RELEASE,Spring Clo ...
- SpringCloud教程第1篇:Eureka(F版本)
一.创建服务注册中心(Eureka组件) 1.1 首先创建一个maven主工程. 1.创建maven项目 是一个主Maven工程,spring Boot版本为2.0.3.RELEASE,Spring ...
- SpringCloud(Finchley版本)中Zull过滤器ResponseBoby返回中文乱码解决方案
Spring Cloud带有"Cloud"的字样,但它并不是云计算解决方案,而是在Spring Boot基础上构建的,用于快速构建分布式系统的通用模式的工具集.使用Spring C ...
- SpringCloud学习(一)服务的注册与发现Eureka(Finchley版本)
创建服务注册中心 在这里,我还是采用Eureka作为服务注册与发现的组件. 首先创建一个空项目 首先创建一个空项目,再创建一个maven项目,首先创建一个主Maven工程,在其pom文件引入依赖,sp ...
- springcloud ribbon Finchley 版本,自定义算法
引用上一个项目,在原有的基础上进行更改,添加springcloud的内荣. eureka-server 和上一个springcloud eureka的一样,没有改动. 添加cloud-api pack ...
- SpringCloud Eureka 报错 无法启动问题
1.SpringCloud Eureka 报错 无法启动基本上都是spring boot的版本与spring cloud的版本不匹配导致的. <dependencyManagement> ...
- 微服务之SpringCloud实战(二):SpringCloud Eureka服务治理
服务治理 SpringCloud Eureka是SpringCloud Netflix微服务套件的一部分,它基于Netflix Eureka做了二次封装,主要完成微服务的服务治理功能,SpringCl ...
随机推荐
- php面向对象深入理解(一)
面向对象(Object Oriented Programming,OOP)的基础知识: 第一个例子: 类Test.class.php <?php class Test{ public $a= ...
- JavaWeb学习篇之----Servlet
今天来继续学习JavaWeb的相关知识,之前都是都介绍一些基本知识,从今天开始我们来说一下如何在服务器编写程序,这里就需要来介绍一下Servlet的相关知识了.Servlet就是一个能够运行在服务器端 ...
- 虚树(树形dp套路)模板——bzoj2286
虚树的核心就是把关键点和关键点的lca重新生成一棵树,然后在这棵树上进行dp https://www.cnblogs.com/zwfymqz/p/9175152.html 写的很好的博客 建立虚树的 ...
- pytorch实现kaggle猫狗识别
参考:https://blog.csdn.net/weixin_37813036/article/details/90718310 kaggle是一个为开发商和数据科学家提供举办机器学习竞赛.托管数据 ...
- Feign Request header is too large
Feign远程调用时数据量过大报错 看异常提示猜测Feign在请求其他服务时,将数据存在了header,导致数据量过大报错 MultiValueMap<String, String> pa ...
- Cstring转char、string、int等数据类型的方法(转载)
Cstring转char.string.int等数据类型的方法 (-- ::) 转载 标签: 杂谈 分类: VC CString 转char * CString cstr; char *p = (LP ...
- C++输入cin详解
输入原理: 程序的输入都建有一个缓冲区,即输入缓冲区.一次输入过程是这样的,当一次键盘输入结束时会将输入的数据存入输入缓冲区,而cin函数直接从输入缓冲区中取数据.正因为cin函数是直接从缓冲区取数据 ...
- C#-Api:身份证识别
ylbtech-C#-Api:身份证识别 通过POST上传base64格式的图片内容,可识别二代身份证.驾照.行驶证.军官证.中华人民共和国往来港澳通行证.台湾居民往来大陆通行证.大陆居民往来台湾通行 ...
- u-boot 的介绍及系统结构
u-boot 介绍 Uboot 是德国 DENX 小组的开发用于多种嵌入式 CPU 的 bootloader 程序, UBoot 不仅仅支持嵌入式 Linux 系统的引导,当前,它还支持 Net ...
- 【笔记篇】斜率优化dp(三) APIO2010特别行动队
旁听了一波给舒老师和学弟的pkuwc面试讲座... 这里有一段隐身的吐槽, 想看的请自己想办法观看. 不想看的跳过这一段看似空白的东西就好了... 刚开始ATP学姐给我们讲了自己面试的时候的事情..描 ...

