Skip to content

Commit

Permalink
modified eureka server port
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuanhuan committed Apr 25, 2019
1 parent a8e4299 commit e7435ee
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions customer-feign/src/main/java/controller/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class HelloController {
@Autowired
HelloService helloService;

@GetMapping(value = "/hi")
public String sayHello(@RequestParam String name) {
@GetMapping(value = "/hello")
public String doHello(@RequestParam String name) {
return helloService.sayHello(name);
}
}
1 change: 1 addition & 0 deletions customer-feign/src/main/java/feign/ClientFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
@Component
@EnableDiscoveryClient
//指定要扫描的feign client的包位置
@EnableFeignClients("service")
public class ClientFeign {
}
3 changes: 1 addition & 2 deletions customer-feign/src/main/java/service/HelloService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package service;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -12,6 +11,6 @@
@FeignClient("eureka-client-hello")
public interface HelloService {

@RequestMapping(value = "/hi", method = RequestMethod.GET)
@RequestMapping(value = "/hello", method = RequestMethod.GET)
String sayHello(@RequestParam(value = "name") String name);
}
2 changes: 1 addition & 1 deletion customer-feign/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ server:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
defaultZone: http://localhost:8762/eureka/
6 changes: 3 additions & 3 deletions customer-ribbon/src/main/java/controller/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class HelloController {
@Autowired
HelloService helloService;

@GetMapping(value = "/hi")
public String hi(@RequestParam String name) {
return helloService.hiService( name );
@GetMapping(value = "/hello")
public String doHello(@RequestParam String name) {
return helloService.sayHello(name);
}
}
4 changes: 2 additions & 2 deletions customer-ribbon/src/main/java/service/HelloService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class HelloService {
@Autowired
RestTemplate restTemplate;

public String hiService(String name) {
return restTemplate.getForObject("http://EUREKA-CLIENT-HELLO/hi?name=" + name, String.class);
public String sayHello(String name) {
return restTemplate.getForObject("http://EUREKA-CLIENT-HELLO/hello?name=" + name, String.class);
}
}
2 changes: 1 addition & 1 deletion customer-ribbon/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ server:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
defaultZone: http://localhost:8762/eureka/
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

@SpringBootApplication
@EnableEurekaClient
//@EnableEurekaClient
@ComponentScan("controller")
public class EurekaClientApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class HelloController {
@Value("${server.port}")
String port;

@RequestMapping("/hi")
public String hello(@RequestParam(value = "name", defaultValue = "foo") String name) {
return "hi " + name + " ,i am from port:" + port;
@RequestMapping("/hello")
public String doHello(@RequestParam(value = "name", defaultValue = "foo") String name) {
return "hello " + name + " ,i am from port:" + port;
}
}
6 changes: 5 additions & 1 deletion eureka-client-hello/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ spring:
server:
port: 18761

#eureka:
# client:
# serviceUrl:
# defaultZone: http://localhost:8761/eureka/
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
defaultZone: http://localhost:8762/eureka/
2 changes: 1 addition & 1 deletion eureka-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring:
name: eureka-server

server:
port: 8761
port: 8762

eureka:
instance:
Expand Down

0 comments on commit e7435ee

Please sign in to comment.