feign test
This commit is contained in:
parent
48b3d32ac6
commit
c09fefd44e
9
pom.xml
9
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.risesoft</groupId>
|
<groupId>net.risesoft</groupId>
|
||||||
<artifactId>demo01</artifactId>
|
<artifactId>demo01</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<name>demo01</name>
|
<name>demo01</name>
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<!--<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>-->
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -156,8 +156,7 @@
|
||||||
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
||||||
<BP_JVM_VERSION>21</BP_JVM_VERSION>
|
<BP_JVM_VERSION>21</BP_JVM_VERSION>
|
||||||
</env>
|
</env>
|
||||||
<name>
|
<name>svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
||||||
svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
|
||||||
<publish>true</publish>
|
<publish>true</publish>
|
||||||
</image>
|
</image>
|
||||||
<docker>
|
<docker>
|
||||||
|
|
|
@ -2,7 +2,9 @@ package net.risesoft.demo;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
|
@EnableDiscoveryClient
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class Demo01Application {
|
public class Demo01Application {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,10 @@ package net.risesoft.demo.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.springframework.cloud.client.ServiceInstance;
|
||||||
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -16,10 +19,13 @@ import net.risesoft.demo.repository.UserRepository;
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
private final DiscoveryClient client;
|
||||||
|
|
||||||
public UserController(UserRepository userRepository) {
|
public UserController(UserRepository userRepository, DiscoveryClient client) {
|
||||||
super();
|
super();
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping({"", "/"})
|
@GetMapping({"", "/"})
|
||||||
|
@ -27,6 +33,13 @@ public class UserController {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
list.add("serverName=" + request.getServerName());
|
list.add("serverName=" + request.getServerName());
|
||||||
list.add("localAddr=" + request.getLocalAddr());
|
list.add("localAddr=" + request.getLocalAddr());
|
||||||
|
|
||||||
|
/*List<ServiceInstance> instances = client.getInstances("demo01");
|
||||||
|
ServiceInstance selectedInstance = instances.get(new Random().nextInt(instances.size()));
|
||||||
|
list.add("serviceId=" + selectedInstance.getServiceId());
|
||||||
|
list.add("host=" + selectedInstance.getHost());
|
||||||
|
list.add("port=" + selectedInstance.getPort());*/
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ management:
|
||||||
exposure:
|
exposure:
|
||||||
include: '*'
|
include: '*'
|
||||||
server:
|
server:
|
||||||
port: 7099
|
port: 8081
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /demo01
|
context-path: /demo01
|
||||||
encoding:
|
encoding:
|
||||||
|
@ -33,7 +33,7 @@ spring:
|
||||||
compatibility-verifier:
|
compatibility-verifier:
|
||||||
enabled: false
|
enabled: false
|
||||||
consul:
|
consul:
|
||||||
host: ${CONSUL_HOST:consul}
|
host: ${CONSUL_HOST:localhost}
|
||||||
port: ${CONSUL_PORT:8500}
|
port: ${CONSUL_PORT:8500}
|
||||||
discovery:
|
discovery:
|
||||||
register-health-check: true
|
register-health-check: true
|
||||||
|
@ -72,6 +72,10 @@ spring:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
allow-circular-references: false
|
allow-circular-references: false
|
||||||
lazy-initialization: false
|
lazy-initialization: false
|
||||||
|
keep-alive: true
|
||||||
|
threads:
|
||||||
|
virtual:
|
||||||
|
enabled: true
|
||||||
docker:
|
docker:
|
||||||
compose:
|
compose:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
Loading…
Reference in New Issue