remove feign-ribbon dependency
fixes gh-41
This commit is contained in:
21
pom.xml
21
pom.xml
@@ -186,20 +186,9 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-ribbon</artifactId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-slf4j</artifactId>
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.12.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Spock -->
|
||||
<dependency>
|
||||
<groupId>org.spockframework</groupId>
|
||||
@@ -237,19 +226,15 @@
|
||||
<version>2.4.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-commons.version>1.1.0.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
<spring-cloud-netflix.version>1.1.0.BUILD-SNAPSHOT</spring-cloud-netflix.version>
|
||||
<archaius.version>0.7.1</archaius.version>
|
||||
<curator.version>2.8.0</curator.version>
|
||||
<!-- TODO: How to not maintain version here AND in spring-cloud-netflix -->
|
||||
<archaius.version>0.7.1</archaius.version>
|
||||
<ribbon.version>2.1.0</ribbon.version>
|
||||
<feign.version>8.10.0</feign.version>
|
||||
<spock.version>1.0-groovy-2.4</spock.version>
|
||||
|
||||
@@ -107,16 +107,6 @@
|
||||
<artifactId>feign-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-ribbon</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-slf4j</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
@@ -169,6 +159,12 @@
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
<version>${spring-cloud-netflix.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
|
||||
@@ -23,8 +23,10 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.netflix.feign.ribbon.CachingSpringLoadBalancerFactory;
|
||||
import org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -33,7 +35,6 @@ import org.springframework.context.annotation.Primary;
|
||||
import feign.Client;
|
||||
import feign.Request;
|
||||
import feign.Response;
|
||||
import feign.ribbon.RibbonClient;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -44,16 +45,21 @@ import feign.ribbon.RibbonClient;
|
||||
@Configuration
|
||||
@ConditionalOnDependenciesPassed
|
||||
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependencies.headers.enabled", matchIfMissing = true)
|
||||
@ConditionalOnClass({ Client.class, RibbonClient.class })
|
||||
@ConditionalOnClass({ Client.class, LoadBalancerFeignClient.class })
|
||||
public class DependencyFeignClientAutoConfiguration {
|
||||
@Autowired
|
||||
private LoadBalancerFeignClient ribbonClient;
|
||||
|
||||
@Autowired
|
||||
private ZookeeperDependencies zookeeperDependencies;
|
||||
|
||||
@Autowired
|
||||
private CachingSpringLoadBalancerFactory loadBalancerFactory;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@SuppressWarnings("deprecation")
|
||||
Client dependencyBasedFeignClient(final LoadBalancerFeignClient ribbonClient,
|
||||
final ZookeeperDependencies zookeeperDependencies) {
|
||||
// TODO: remove dependency on feign-ribbon
|
||||
return new RibbonClient() {
|
||||
Client dependencyBasedFeignClient() {
|
||||
return new LoadBalancerFeignClient(new Client.Default(null, null), loadBalancerFactory) {
|
||||
@Override
|
||||
public Response execute(Request request, Request.Options options)
|
||||
throws IOException {
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
<version>${spring-cloud-netflix.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.zookeeper.sample;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -26,9 +24,12 @@ import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -39,7 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@EnableAutoConfiguration
|
||||
@EnableDiscoveryClient
|
||||
@RestController
|
||||
@Slf4j
|
||||
@EnableFeignClients
|
||||
public class SampleZookeeperApplication {
|
||||
|
||||
@Value("${spring.application.name:testZookeeperApp}")
|
||||
@@ -51,21 +52,37 @@ public class SampleZookeeperApplication {
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RelaxedPropertyResolver resolver;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleZookeeperApplication.class, args);
|
||||
}
|
||||
@Autowired
|
||||
private AppClient appClient;
|
||||
|
||||
@RequestMapping("/")
|
||||
public ServiceInstance lb() {
|
||||
return loadBalancer.choose(appName);
|
||||
}
|
||||
|
||||
@RequestMapping("/hi")
|
||||
public String hi() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
@RequestMapping("/self")
|
||||
public String self() {
|
||||
return appClient.hi();
|
||||
}
|
||||
|
||||
@RequestMapping("/myenv")
|
||||
public String env(@RequestParam("prop") String prop) {
|
||||
String property = new RelaxedPropertyResolver(env).getProperty(prop, "Not Found");
|
||||
return property;
|
||||
}
|
||||
|
||||
@FeignClient("testZookeeperApp")
|
||||
interface AppClient {
|
||||
@RequestMapping(value = "/hi", method = RequestMethod.GET)
|
||||
String hi();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleZookeeperApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,7 @@ endpoints:
|
||||
sensitive: false
|
||||
|
||||
logging.level:
|
||||
org.apache.zookeeper.ClientCnxn: WARN
|
||||
org.apache.zookeeper.ClientCnxn: WARN
|
||||
|
||||
#spring.cloud.zookeeper.dependencies:
|
||||
# - testZookeeperApp: ~
|
||||
Reference in New Issue
Block a user