1.在pom.xml中增長eureka的相關依賴linux
<!-- 註冊中心 --> <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.propertiesweb
http://帳號:密碼@eureka-server1:8888/eureka/(網關),(逗號隔開能夠有多個網關)http://帳號:密碼@eureka-server2:8888/eureka/spring
linux中的hosts文件在 etc下 進入hosts配置網關例如 :eureka-server1,eureka-server2
服務器
網關須要在linux中 配置hosts路由 (配置網關須要和eureka-client.properties中的映射ip地址保持一致)
spa
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的服務註冊監聽code
<!-- eureka服務註冊監聽器 --> <listener> <description>eurekaListener</description> <listener-class>com.we.core.eureka.client.RegisterEurekaService</listener-class> </listener>
重啓項目看控制檯是否是能夠加載到eurekaorm