Skip to content

Commit 33edcac

Browse files
committed
random uuid service using feign
1 parent 4279465 commit 33edcac

File tree

8 files changed

+123
-0
lines changed

8 files changed

+123
-0
lines changed

.java-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.8

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<module>spikes</module>
2020
<module>discovery-service</module>
2121
<module>discovery-client</module>
22+
<module>random-service</module>
23+
<module>random-client</module>
2224
</modules>
2325

2426
<properties>

random-client/pom.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<artifactId>springbootcamp</artifactId>
10+
<groupId>com.github.jangalinski.springboot</groupId>
11+
<version>1.0-SNAPSHOT</version>
12+
</parent>
13+
14+
<artifactId>random-client</artifactId>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework.cloud</groupId>
19+
<artifactId>spring-cloud-starter-eureka</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.springframework.cloud</groupId>
23+
<artifactId>spring-cloud-starter-feign</artifactId>
24+
</dependency>
25+
</dependencies>
26+
27+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.github.jangalinski.springboot;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7+
import org.springframework.cloud.netflix.feign.EnableFeignClients;
8+
import org.springframework.cloud.netflix.feign.FeignClient;
9+
import org.springframework.context.annotation.Bean;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RequestMethod;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
@SpringBootApplication
15+
@EnableEurekaClient
16+
@EnableFeignClients
17+
@RestController
18+
public class RandomClientApplication {
19+
20+
public static void main(String[] args) {
21+
SpringApplication.run(RandomClientApplication.class, args);
22+
}
23+
24+
@Autowired
25+
private RandomClient randomClient;
26+
27+
@RequestMapping(value = "/random", method = RequestMethod.GET)
28+
public String getRandom() {
29+
return "random-" + randomClient.getRandom();
30+
}
31+
32+
33+
@FeignClient("random-service")
34+
interface RandomClient {
35+
36+
@RequestMapping(method = RequestMethod.GET, value = "/random")
37+
String getRandom();
38+
}
39+
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spring.application.name: random-client
2+
server.port: 0

random-service/pom.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<artifactId>springbootcamp</artifactId>
9+
<groupId>com.github.jangalinski.springboot</groupId>
10+
<version>1.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>random-service</artifactId>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.springframework.cloud</groupId>
18+
<artifactId>spring-cloud-starter-eureka</artifactId>
19+
</dependency>
20+
</dependencies>
21+
22+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.github.jangalinski.springboot;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RequestMethod;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
import java.util.UUID;
11+
12+
@SpringBootApplication
13+
@EnableEurekaClient
14+
@RestController
15+
public class RandomServiceApplication {
16+
17+
public static void main(String[] args) {
18+
SpringApplication.run(RandomServiceApplication.class, args);
19+
}
20+
21+
@RequestMapping(value = "/random", method = RequestMethod.GET)
22+
public String getRandomUuid() {
23+
return UUID.randomUUID().toString();
24+
}
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spring.application.name: random-service
2+
server.port: 0

0 commit comments

Comments
 (0)