Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1027e80
commit 71ff754
Showing
12 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spring-cloud-eureka-client/src/main/java/com/xjtushilei/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.xjtushilei; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author shilei | ||
* @Date 2017/6/12. | ||
*/ | ||
@RestController | ||
public class HelloController { | ||
|
||
@Value("${server.port}") | ||
String port; | ||
|
||
@RequestMapping("/hi") | ||
public String hi() { | ||
return port + " 端口为您服务!"; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
spring-cloud-eureka-client/src/main/resources/application-peer1.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
server.port=8084 | ||
spring.application.name=eureka-client-1 | ||
eureka.client.service-url.defaultZone=http://peer1:8761/eureka/,http://peer2:8762/eureka/ |
3 changes: 3 additions & 0 deletions
3
spring-cloud-eureka-client/src/main/resources/application-peer2.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
server.port=8085 | ||
spring.application.name=eureka-client-1 | ||
eureka.client.service-url.defaultZone=http://peer1:8761/eureka/,http://peer2:8762/eureka/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.xjtushilei</groupId> | ||
<artifactId>spring-cloud-eureka-consumer</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>spring-cloud-eureka-consumer</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>com.xjtushilei</groupId> | ||
<artifactId>spring-cloud-simple</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
|
||
<dependencies> | ||
<!--远程调用--> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-feign</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
21 changes: 21 additions & 0 deletions
21
spring-cloud-eureka-consumer/src/main/java/com/xjtushilei/ConsumerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.xjtushilei; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author shilei | ||
* @Date 2017/6/13. | ||
*/ | ||
@RestController | ||
public class ConsumerController { | ||
|
||
@Autowired | ||
HelloRemoteInterface helloRemoteInterface; | ||
|
||
@RequestMapping("/hello") | ||
public String hello() { | ||
return helloRemoteInterface.hi(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
spring-cloud-eureka-consumer/src/main/java/com/xjtushilei/HelloRemoteInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.xjtushilei; | ||
|
||
import org.springframework.cloud.netflix.feign.FeignClient; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
/** | ||
* @author shilei | ||
* @Date 2017/6/13. | ||
*/ | ||
@Component | ||
@FeignClient(name = "eureka-client-1") | ||
public interface HelloRemoteInterface { | ||
|
||
@RequestMapping(value = "/hi") | ||
public String hi(); | ||
} |
16 changes: 16 additions & 0 deletions
16
...ud-eureka-consumer/src/main/java/com/xjtushilei/SpringCloudEurekaConsumerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.xjtushilei; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
import org.springframework.cloud.netflix.feign.EnableFeignClients; | ||
|
||
@SpringBootApplication | ||
@EnableEurekaClient | ||
@EnableFeignClients | ||
public class SpringCloudEurekaConsumerApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringCloudEurekaConsumerApplication.class, args); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
spring-cloud-eureka-consumer/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
server: | ||
port: 8086 | ||
|
||
spring: | ||
application: | ||
name: eureka-consumer | ||
|
||
eureka: | ||
client: | ||
service-url: | ||
defaultZone: http://localhost:8761/eureka/ |
14 changes: 14 additions & 0 deletions
14
spring-cloud-eureka-server/src/main/resources/application-single.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server: | ||
port: 8761 | ||
|
||
spring: | ||
application: | ||
name: eureka-server | ||
|
||
eureka: | ||
instance: | ||
lease-expiration-duration-in-seconds: 6 | ||
lease-renewal-interval-in-seconds: 2 | ||
client: | ||
service-url: | ||
defaultZone: http://localhost:8761/eureka/ |