SpringCloud微服务(基于Eureka+Feign+Hystrix+Zuul)
一、搭建注册中心
1.1、创建一个cloud-service项目

1.2:POM文件依赖
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4 <modelVersion>4.0.0</modelVersion>
5
6 <groupId>com.tiandy</groupId>
7 <artifactId>cloud-service</artifactId>
8 <version>0.0.1-SNAPSHOT</version>
9 <packaging>jar</packaging>
10
11 <name>cloud-service</name>
12 <description>Demo project for Spring Boot</description>
13
14 <parent>
15 <groupId>org.springframework.boot</groupId>
16 <artifactId>spring-boot-starter-parent</artifactId>
17 <version>1.5.9.RELEASE</version>
18 <relativePath/> <!-- lookup parent from repository -->
19 </parent>
20
21 <properties>
22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24 <java.version>1.8</java.version>
25 <spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
26 </properties>
27
28 <dependencies>
29
30 <dependency>
31 <groupId>org.springframework.boot</groupId>
32 <artifactId>spring-boot-starter-web</artifactId>
33 </dependency>
34
35 <dependency>
36 <groupId>org.springframework.cloud</groupId>
37 <artifactId>spring-cloud-starter-eureka</artifactId>
38 </dependency>
39 <!-- @HystrixCommand注解 -->
40 <dependency>
41 <groupId>com.netflix.hystrix</groupId>
42 <artifactId>hystrix-javanica</artifactId>
43 </dependency>
44 <dependency>
45 <groupId>org.springframework.cloud</groupId>
46 <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
47 </dependency>
48 <!-- 声明调用 -->
49 <dependency>
50 <groupId>org.springframework.cloud</groupId>
51 <artifactId>spring-cloud-starter-openfeign</artifactId>
52 </dependency>
53 <!-- 服务容错 -->
54 <dependency>
55 <groupId>org.springframework.cloud</groupId>
56 <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
57 </dependency>
58
59 <!--网关zuul-->
60 <dependency>
61 <groupId>org.springframework.cloud</groupId>
62 <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
63 </dependency>
64
65 <!--实体中的Date注解,不用get set-->
66 <dependency>
67 <groupId>org.projectlombok</groupId>
68 <artifactId>lombok</artifactId>
69 </dependency>
70
71
72 <dependency>
73 <groupId>org.springframework.boot</groupId>
74 <artifactId>spring-boot-starter-test</artifactId>
75 <scope>test</scope>
76 </dependency>
77
78
79 </dependencies>
80
81 <dependencyManagement>
82 <dependencies>
83 <dependency>
84 <groupId>org.springframework.cloud</groupId>
85 <artifactId>spring-cloud-dependencies</artifactId>
86 <version>${spring-cloud.version}</version>
87 <type>pom</type>
88 <scope>import</scope>
89 </dependency>
90 </dependencies>
91 </dependencyManagement>
92
93 <build>
94 <plugins>
95 <plugin>
96 <groupId>org.springframework.boot</groupId>
97 <artifactId>spring-boot-maven-plugin</artifactId>
98 </plugin>
99 </plugins>
100 </build>
101
102 </project>


