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

http://賬號:密碼@eureka-server1:8888/eureka/(網關),(逗號隔開可以有多個網關)http://賬號:密碼@eureka-server2:8888/eureka/
linux中的hosts文件在 etc下 進入hosts配置網關例如 :eureka-server1,eureka-server2
網關需要在linux中 配置hosts路由 (配置網關需要和eureka-client.properties中的映射ip地址保持一致)
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://*****:*****@eureka-server1:8888/eureka/,http://*****:*****@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
