SpringCloud微服务实战:一、Eureka注册中心服务端

1.项目启动类application.java类名上增加@EnableEurekaServer注解,声明是注册中心
 1 import org.springframework.boot.SpringApplication;
 2 import org.springframework.boot.autoconfigure.SpringBootApplication;
 3 import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
 4 @SpringBootApplication
 5 @EnableEurekaServer
 6 public class EurekaApplication { 7 public static void main(String[] args) { 8 SpringApplication.run(EurekaApplication.class, args); 9  } 10 }
2.application.yml配置:
 1 #配置注册中心服务端信息
 2  eureka:
 3  client:
 4  service-url:
 5  defaultZone: http://localhost:8762/eureka/
 6  #配置是否显示在注册中心上
 7  register-with-eureka: false
 8  #自我保护机制,开发环境可以关闭,生产环境必须开启 9  server: 10 enable-self-preservation: false 11  #配置在注册中心显示的名字 12  spring: 13  application: 14  name: eureka 15  #配置服务端口 16  #server: 17 # port: 8761
3.pom.xml配置:
 1 
 2 
 4  4.0.0
 5 
 6  com.kjm
 7  eureka
 8  0.0.1-SNAPSHOT
 9  jar
10 
11  eureka
12  Eureka服务端
13 
14  
15  org.springframework.boot
16  spring-boot-starter-parent
17  2.1.0.RELEASE
18   
19  
20  
21  UTF-8
22  UTF-8
23  1.8
24  Greenwich.M3
25  
26  
27  
28  org.springframework.cloud
29  spring-cloud-starter-netflix-eureka-server
30  
31  
32  org.springframework.boot
33  spring-boot-starter-test
34  test
35  
36  
37  
38  
39  
40  org.springframework.cloud
41  spring-cloud-dependencies
42  ${spring-cloud.version}
43  pom
44  import
45  
46  
47  
48  
49  
50  
51  org.springframework.boot
52  spring-boot-maven-plugin
53  
54  
55  
57  
58  
59  spring-milestones
60  Spring Milestones
61  https://repo.spring.io/milestone
62  
63  false
64  
65  
66  
67 
4.打包:mvn clean install -Dmaven.test.skip=true
5.启动注册中心服务端:java -jar eureka-0.0.1-SNAPSHOT.jar

你可能感兴趣的:(SpringCloud微服务实战:一、Eureka注册中心服务端)