eureka配置服務端
阿新 • • 發佈:2018-12-14
pom.xml檔案格式如下:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency>
新建application.yml檔案,加入如下內容。
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
4.在src/main/java 下新建包com.helloworld.eureka
5.在com.helloworld.eureka包下新建類:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
6.執行EurekaServer類,啟動完成後訪問http://localhost:8761/,看到eureka server的頁面啟動完成了