首页 > 其他 > 详细

eureka在项目中的简单使用配置

时间:2019-05-21 13:58:07      阅读:188      评论:0      收藏:0      [点我收藏+]

1.在pom.xml中增加eureka的相关依赖

<!-- 注册中心 -->
<dependency>
   <groupId>com.we.core.eureka</groupId>
   <artifactId>we-core-eureka-client</artifactId>
   <version>1.0.0</version>
   <exclusions>
      <exclusion>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
      </exclusion>
      <exclusion>
         <groupId>org.springframework</groupId>
         <artifactId>spring-test</artifactId>
      </exclusion>

      <exclusion>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-core</artifactId>
      </exclusion>
      <exclusion>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-databind</artifactId>
      </exclusion>
      <exclusion>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-annotations</artifactId>
      </exclusion>
      <exclusion>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-dataformat-xml</artifactId>
      </exclusion>
   </exclusions>
</dependency>

2.增加配置文件在resources下新加eureka-client.properties

技术分享图片

 

eureka.name=QDEDU_ACTIVITY
eureka.port=8080
#客户识别此服务的虚拟主机名,这里指的是eureka服务本身(相当于boot中的serviceId)
eureka.vipAddress=${eureka.name}


#设置为false,因为该配置适用于eureka服务器本身的eureka客户端。
#在eureka服务器中运行的eureka客户端需要连接到其他区域中的服务器。
#对于其他应用程序,不应设置(默认为true),以实现更好的基于区域的负载平衡。
#eureka.preferSameZone=false

#如果要使用基于DNS的查找来确定其他eureka服务器(请参见下面的示例),请更改此选项
eureka.shouldUseDns=false
eureka.us-east-1.availabilityZones=default
#由于shouldUseDns为false,因此我们使用以下属性来明确指定到eureka服务器的路由(eureka Server地址)
#也可以使用host文件中:机器名映射IP地址,便于日后维护
eureka.serviceUrl.default=http://tfedu:tfedu123@eureka-server1:8888/eureka/,http://tfedu:tfedu123@eureka-server2:8888/eureka/

 3.在web.xml中增加eureka的服务注册监听

<!-- eureka服务注册监听器 -->
    <listener>
        <description>eurekaListener</description>
        <listener-class>com.we.core.eureka.client.RegisterEurekaService</listener-class>
    </listener>

重启项目看控制台是不是可以加载到eureka

 

eureka在项目中的简单使用配置

原文:https://www.cnblogs.com/houpengwei/p/10899396.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!