pom

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

<!-- cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
</dependencies>

<!-- cloud 依赖-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

pom

1
2
3
4
5
6
7
8
9
10
11
12
13
eureka:
instance:
hostname: localhost
preferIpAddress: true
client:
# 服务器端不注册eureka(默认true)
# registerWithEureka: true
# 服务器端不需要抓取服务列表(默认true)
# fetchRegistry: false
# 注册url(配置之后报错Reached through: #include "navbar.ftl" [in template "eureka/status.ftl" at line 22, column 7])
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
enabled: true #需要手动开启

当主页404加上

1
2
3
spring:
freemarker:
preferFileSystemAccess: false

Application

启动类加上注释

1
2
3
@EnableEurekaServer
@EnableFeignClients
@EnableEurekaClient

FeignClient

1
2
3
4
5
6
@FeignClient(name="sc")
public interface ScappFeignClient {
@RequestMapping(value = "/sciUserInfo/queryOneById", method = RequestMethod.GET)
String findById(@RequestParam(value = "suiId", required = false) Long suiId);
}